Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Mar 2011
    Posts
    212
    Thanks
    10
    Thanked 1 Time in 1 Post

    Exclamation If/Else clauses in wordpress site

    Im working on a wordpress site for alliance-fl.com. What I want to do I *thought* would be simple, but its turning out to be a lot more complicated that I thought.

    On the front page - where there is the featured products slider, I have a product that doesnt have a price yet. I want, instead of showing no price, to echo "Coming Soon"

    I want to do the same for the single product description, the products page, and the products sidebar that is within the single product page. I'm not really familiar with how to do this as my knowledge of php is limited and I mainly work is css and html. How would I do this?

  • #2
    New Coder
    Join Date
    Feb 2011
    Posts
    56
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Can you provide the name of the WP commerce plugin and slider?

  • #3
    Regular Coder
    Join Date
    Jun 2010
    Posts
    121
    Thanks
    0
    Thanked 3 Times in 3 Posts
    There is no way of getting around this you're going to have to do some custom manipulation of the code. Depending on what you are using, i have done this in opencart and it shouldn't be much different. Locate the template file you are using and find the location where the price is being printed. let's say it's stored in the variable $price.
    Code:
    if($price == '$0.00'){
    echo '<h2>Coming Soon</h2>';
    }else{
    echo $price;
    }
    For more tutorials on my please check out my youtube channel here

  • #4
    Regular Coder
    Join Date
    Mar 2011
    Posts
    212
    Thanks
    10
    Thanked 1 Time in 1 Post
    So far that didnt work unfortunately, sorry about the late reply. The plugin I am using is woocommerce.

  • #5
    New Coder
    Join Date
    Feb 2011
    Posts
    56
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Try adding to you functions.php file your (inside theme directory) something like
    PHP Code:

    add_filter
    ('woocommerce_empty_price_html''coming_soon');
     
    function 
    coming_soon() {
         return 
    'Coming Soon';

    If it doesnt work there add the code above to wp-content/plugins/woocommerce/includes/wc-core-functions.php file.. adding it to functions.php is a better option though.
    Last edited by neptune1; 04-15-2014 at 05:48 PM.

  • Users who have thanked neptune1 for this post:

    lmorales (04-15-2014)

  • #6
    Regular Coder
    Join Date
    Mar 2011
    Posts
    212
    Thanks
    10
    Thanked 1 Time in 1 Post
    Quote Originally Posted by neptune1 View Post
    Try adding to you functions.php file your (inside theme directory) something like
    PHP Code:

    add_filter
    ('woocommerce_empty_price_html''coming_soon');
     
    function 
    coming_soon() {
         return 
    'Coming Soon';

    If it doesnt work there add the code above to wp-content/plugins/woocommerce/includes/wc-core-functions.php file.. adding it to functions.php is a better option though.
    That did it! Thank you so much! is there an easy way to make it output red?

  • #7
    New Coder
    Join Date
    Feb 2011
    Posts
    56
    Thanks
    5
    Thanked 2 Times in 2 Posts
    no sweat! you can try
    PHP Code:

    add_filter
    ('woocommerce_empty_price_html''coming_soon'); 

    function 
    coming_soon() {
         return 
    '<span style="color:#FF0000">Coming Soon</span>';

    Last edited by neptune1; 04-15-2014 at 06:29 PM.

  • Users who have thanked neptune1 for this post:

    lmorales (04-15-2014)

  • #8
    Regular Coder
    Join Date
    Mar 2011
    Posts
    212
    Thanks
    10
    Thanked 1 Time in 1 Post
    Winner winner chicken dinner, you sir, are a life saver.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •