I'm developing a Wordpress-based website and posting on it requires subscription plan selection, which is part of the theme that's used. However, I don't intend on implementing different subscription plans and there would be only one free plan, so manual selection from the users is not needed. This is the code of the plan selection option that gets shown to the user when posting:
<li <?php echo $class_select; ?> data-sku="<?php echo $package->sku ?>" data-id="<?php echo $package->ID ?>" data-price="<?php echo $package->et_price; ?>"
<?php if( $package->et_price ) { ?>
data-label="<?php printf(__("You have selected: %s", ET_DOMAIN) , $package->post_title ); ?>"
<?php } else { ?>
data-label="<?php _e("You are currently using the 'Free' plan", ET_DOMAIN); ?>"
<?php } ?>
>
<span class="price">
<?php if( $package->et_price ) {
ae_price($package->et_price);
}else {
_e("Free", ET_DOMAIN);
} ?>
</span>
<span class="title-plan">
<span class="package-title"><?php echo $package->post_title .' - '; ?></span>
<span class="package-limit"><?php if($text) { echo $text; } ?></span>
<span><?php echo $package->post_content; ?></span>
</span>
<?php _e( 'Select' , ET_DOMAIN ); ?>
<div class="clearfix"></div>
</li>
I think the way to go would be to make it so that it automatically selects the one available for selection plan and hide this element from the user, so that he doesn't actually see all this and save him one step when posting. I'm not really sure how this could be accomplished, though - do you have any ideas or suggestions?
I've been developing this website for the last 4 months and this is the very last thing remaining before its completion and then it would be ready to launch. Any help would be greatly appreciated. Thank you.
Related
I'm not very familiar with PHP so it would be amazing if someone could give me a hand on this.
We are using Vik Rent Car WordPress plugin (a booking system for car rental). We have set 3 pricing types for customers to choose from, so after they've selected dates and see the search results with available cars, these 3 options show up.
Now by default, the first and pre-selected option is the cheapest option, but we need this to be the other way around, so the first and pre-selected option should be the most expensive one.
By coincidence, the name of the most expensive option starts with a "C" and the cheapest with an "Y", so if it could be sorted by name that would also be a solution.
This is the snippet which i believe contains the code for showing the search results.
Is there anyone who could tell me how to insert a code to make these search results sorted by Price (descending) or by name (ascending).
Any help would be highly appreciated. Thanks.
<div class="car_prices table-responsive">
<span class="vrhword"><?php echo JText::_('VRPRICE'); ?></span>
<table class="table">
<?php
$loopnum = 0;
foreach ($tars as $k => $t) {
$has_promotion = array_key_exists('promotion', $t) ? true : false;
?>
<tr>
<td>
<label for="pid<?php echo $t['idprice']; ?>"<?php echo $has_promotion === true ? ' class="vrc-label-promo-price"' : ''; ?>>
<div class="vrc-showprc-priceinfo">
<span class="vrc-showprc-pricename"><?php echo VikRentCar::getPriceName($t['idprice'], $vrc_tn); ?></span>
<span class="vrc-showprc-pricecost">
<?php echo "<span class=\"vrc_currency\">".$currencysymb."</span> <span class=\"vrc_price\">".($tax_summary ? VikRentCar::numberFormat($t['cost']) : VikRentCar::numberFormat(VikRentCar::sayCostPlusIva($t['cost'], $t['idprice'])))."</span>"; ?>
</span>
</div>
<?php
if (strlen($t['attrdata'])) {
?>
<div class="vrc-showprc-priceattr">
<?php echo VikRentCar::getPriceAttr($t['idprice'], $vrc_tn).": ".$t['attrdata']; ?>
</div>
<?php
}
?>
</label>
</td>
<td>
<input type="radio" name="priceid" id="pid<?php echo $t['idprice']; ?>" value="<?php echo $t['idprice']; ?>"<?php echo ($loopnum == 0 ? " checked=\"checked\"" : ""); ?>/>
</td>
</tr>
<?php
$loopnum++;
}
?>
</table>
</div>
I've created custom post type as single-service.php and I have several custom taxonomies under service posts like education, recruit and health.
I currently created some queries and under each query, I want to create a button which direct the users the contact form page of that service. It is like when you get into a single service page which is categorized under education there will a button directs them to education contact form page likewise for recruit page.
I have tried below link but somehow it does not work. I am not sure whether I am using correct code or where do I make mistake
<?php if (in_category( 'education', $post->ID )) : ?>
<?php echo '<div class="button">Contact us</div>'; ?>
<?php elseif (in_category('recruit', $post->ID)) :?>
<?php echo '<div class="button">Contact us</div>'; ?>
<?php elseif (in_category('health', $post->ID)) :?>
<?php echo '<div class="button">Contact us</div>'; ?>
<?php endif;?>
I solve my problem by creating two custom fields in the template page and linking them with :
<div class="service-button">
<?php $info = get_post_meta(get_the_ID(), '_post_info', true); if (!$info) $info = array(); ?>
<a class="form" style="background-color:<?php echo $info['color'] ?>" href="<?php echo $info['form'] ?>">Contact us</a>
<?php if ($info['website']) : ?>
<a class="website" style="background-color:<?php echo $info['color'] ?>" href="http://<?php echo $info['website'] ?>"><?php echo $info['website'] ?></a>
<?php endif; ?>
</div>
I'm trying to edit the template and I need to add "Starting from" in front of the prices on the catalog page (and then maybe the product page, but one step at a time)
I've located where it echos the price in the tpl file
<p class="price">
<?php if (!$product['special']) { ?>
<?php echo $product['price']; ?>
<?php } else { ?>
<span class="price-new"><?php echo $product['special']; ?></span> <span class="price-old"><?php echo $product['price']; ?></span>
<?php } ?>
What I tried was to add a row in the oc_product table called starting_from and manually enter "Starting from" in each one. (there are only 6 products for now).
With very little knowlegde i added
<?php echo $product['starting_from']; ?>
so it then looked like this
<p class="price">
<?php if (!$product['special']) { ?>
<?php echo $product['starting_from']; ?>
<?php echo $product['price']; ?>
<?php } else { ?>
<span class="price-new"><?php echo $product['special']; ?></span> <span class="price-old"><?php echo $product['price']; ?></span>
<?php } ?>
Shockingly, it didn't work.
Can someone try and explain the magnitude of my errors, please?
And maybe help me out.
Thank
If your want to simply add the hardcoded string Starting from, you can do:
<p class="price">Starting from
<?php if (!$product['special']) { ?>
<?php echo $product['price']; ?>
<?php } else { ?>
<span class="price-new"><?php echo $product['special']; ?></span> <span class="price-old"><?php echo $product['price']; ?></span>
<?php } ?>
Actually, if I got you right, this is very basic, so I'd recommend some PHP tutorial to start with.
hope you can help.
I need to do the following, this is using Advanced Custom Fields in Wordpress 4.8
Display an Button if
A: The Event Date has not passed (i.e. the Event is finished)
AND
B: The Buy Ticket Link field has a value in it.
I have succeeded with A using the code below but I cannot work out how to combine this with B, using ACF.
I have looked at the ACF support post about hiding fields and the page is here: https://www.advancedcustomfields.com/resources/hiding-empty-fields/ but I don't have the skills to combine these two. I would hugely appreciate any help here please.
<?php
$eventDate = get_field('event_date', false, false);
$today = (date('Y-m-d'));
?>
<?php if ($eventDate >=$today) { ?>
<div class="tickets">
<a class="btn-primary" href="<?php echo the_field('buy_link') ?>" target="_blank">
Buy Tickets</a>
</div>
<?php
} else { ?>
<div class="tickets">
<div class="btn-primary" href="" target="_blank" style="color: white">
This is an old event. Tickets are no longer on sale.</div>
</div>
<?php } ?>
Don't overcomplicate it -
If you want to have an extra condition, you can specify it in your conditional statement.
<?php
$eventDate = get_field('event_date', false, false);
$today = (date('Y-m-d'));
$ticketLink = get_field('buy_link');
?>
<?php if ($eventDate >= $today && $ticketLink) { ?>
<div class="tickets">
<a class="btn-primary" href="<?php echo get_field('buy_link') ?>" target="_blank">
Buy Tickets</a>
</div>
<?php
} else { ?>
<div class="tickets">
<div class="btn-primary" href="#" style="color: white">
This is an old event. Tickets are no longer on sale.</div>
</div>
<?php } ?>
Read more about your logical operators here : Logical Operators
Having a bit of a problem, i'm using ACF for WordPress, i have defined the color picker on the services template which color codes the page heading in a color you select. This template then has a page link which relates to another template: case studies - the case studies template has a select option where you select the page from services that relates to the case study. I can get those values out as it is on the case studies template. How do i go about getting the color picker value from the services page and apply the color to the case studies page? Here is what i have done so far;
<div class="caseStudies">
<h1 class="pageTitle uppercase"><?php echo the_title(); ?></h1>
<div class="caseStudyIntro"><?php echo the_content(); ?></div>
<?php
foreach($caseStudyChildren as $caseStudies)
{
$cStudyId = $caseStudies->ID;
$cStudyThumbnail = get_field("thumbnail_image", $cStudyId);
$cStudyRelation = get_field("case_study_relation", $cStudyId);
$cStudyContent = get_field("case_study_content", $cStudyId);
?>
<div class="caseStudyItem">
<div class="col-md-3 noPaddingLeft">
<a href="<?php echo get_permalink($cStudyId); ?>">
<img src="<?php echo $cStudyThumbnail['url']; ?>" alt="<?php echo $cStudyThumbnail['alt']; ?>" class="img-thumbnail cStudyThumb" />
</a>
</div>
<div class="col-md-9 noPadding">
<div class="content">
<h1 class="title uppercase">
<a href="<?php echo get_permalink($cStudyId); ?>" class="dark-black">
<?php echo get_the_title($cStudyId); ?> <?php echo '- '.$cStudyRelation; ?>
</a>
</h1>
<div class="study">
<?php echo wp_trim_words($cStudyContent, 40, '...'); ?>
</div>
Read More...
</div>
</div>
</div>
<div class="clearfix"></div>
<?php
}/* foreach end */?>
</div>
This line here is where i am adding the services link that relates to the case study (so it almost acts like a tag)
<?php echo get_the_title($cStudyId); ?> <?php echo '- '.$cStudyRelation; ?>
Backend Configuration
Hope that made some sense, if not let me know and i can add to it more. PHP newbie here so go easy one me, haha!
Thanks.
Managed to figure this out in the end. I've got the relationship to the page coming out now and now i've got the color custom field that was defined on the services template coming out on the case studies page.
So i defined the field name in a variable;
$cStudyRelationship = get_field("service_case_study_relationship", $cStudyId);
Then did the following;
$cStudyRelationshipId = '';
$caseStudyTitleColor = '#000';
if(isset($cStudyRelationship[0])){
$cStudyRelationshipId = $cStudyRelationship[0]->ID;
$caseStudyTitleColor = get_field("case_study_title_colour",$cStudyRelationship[0]->ID);
$caseStudyTitleColor = '#'.ltrim(trim($caseStudyTitleColor),'#');
} ?>
So built up the array for the color field created in ACF and then echoed that out against the ID the case study was related to. Hope that makes sense! Not the best at explaining stuff as you can tell.
The last piece of the jigsaw was to apply the color value against the page relationship page title;
<?php echo get_the_title($cStudyId); ?> <?php echo '- '?> <span class="colouredTitle" style="color:<?php echo $caseStudyTitleColor; ?>;"><?php echo ($cStudyRelationship[0]->post_title); ?></span>
Thank you to those that have taken the time out to contribute to this question.