WordPress.org

Ready to get started?Download WordPress

Forums

  1. RapBatLe
    Member
    Posted 1 year ago #

    Hi, i have a problem with display prices on loop page. When product have 2 prices (normal and sale) , this prices are same class and same tag. see this image in firebug image
    I need to separate class for regural price and sale price , because is look bad, see this image or visit site and see this to home page site

    http://wordpress.org/extend/plugins/woocommerce/

  2. RapBatLe
    Member
    Posted 1 year ago #

    I test demo version of our site and i see that <span class="amount">23.00</span> is child of tag <del></del> and sale price child of tag <ins></ins>

  3. RapBatLe
    Member
    Posted 1 year ago #

    if ($this->price!=='') :
    				if ($this->variation_has_sale_price) :
    					$price .= '<del>'.woocommerce_price( $this->regular_price ).'</del> <ins>'.woocommerce_price( $this->sale_price ).'</ins>';
    					$price = apply_filters('woocommerce_variation_sale_price_html', $price, $this);
    				else :
    					$price .= woocommerce_price( $this->price );
    					$price = apply_filters('woocommerce_variation_price_html', $price, $this);
    				endif;
    			endif;

    this code i extract from classes/class-wc-product-variation.php and you see this that tags <del></del> and <ins></ins> is present but doesn't work :( I comment complete this if and also no stress code work perfectly, so problem is in another thing

  4. samueljeden
    Member
    Posted 1 year ago #

    You are only looking at the variation code there not a simple product.

    Which is not for showing on the front end where you have screenshot.

    Which version are you using?

  5. RapBatLe
    Member
    Posted 1 year ago #

    3.4.1 version wordpress, i understand your ideea, can you help me how i can make different class for sale price? i'm doing this in templates/loop/price.php

    Look like this ->

    <?php
    /**
     * Loop Price
     */
    
    global $product;
    ?>
    
    <?php if ($price_html = $product->regular_price) : ?>
    	<span class="price"><?php echo $price_html; ?></span>
    <?php endif; ?>
    <?php if ($price_html2 = $product->sale_price) : ?>
    	<span class="price2"><?php echo $price_html2; ?></span>
    <?php endif; ?>
    
    <?php
    /*
    
    <?php if ($price_html = $product->get_price_html()) : ?>
    	<span class="price"><?php echo $price_html; ?></span>
    <?php endif; ?>
    */
    
     ?>

    it's work good but problems: currency script doesn't work i can't put them manualy with echo, and two zero at end of price are displaying, he doesn't cut. watch an example

    image1
    image2

  6. samueljeden
    Member
    Posted 1 year ago #

    if ($product->is_on_sale) :
    					$price .= '<del>'.woocommerce_price( $product->regular_price ).'</del> <ins>'.woocommerce_price( $product->sale_price ).'</ins>';
    					$price = apply_filters('woocommerce_variation_sale_price_html', $price, $this);
    				else :
    					$price .= woocommerce_price( $product->price );
    					$price = apply_filters('woocommerce_variation_price_html', $price, $this);
    				endif;
    echo $price;
  7. samueljeden
    Member
    Posted 1 year ago #

    Something like that could possibly work?

  8. samueljeden
    Member
    Posted 1 year ago #

    or if you want it like your code above.

    try this.

    <?php
    /**
     * Loop Price
     */
    
    global $woocommerce, $product;
    ?>
    
    <?php
    
    if ($product->is_on_sale) :
    					$price .= '<span class="price">'.woocommerce_price( $product->regular_price ).'</span> <span class="price2">'.woocommerce_price( $product->sale_price ).'</span>';
    					$price = apply_filters('woocommerce_sale_price_html', $price, $this);
    				else :
    					$price .= woocommerce_price( $product->price );
    					$price = apply_filters('woocommerce_price_html', $price, $this);
    				endif;
    echo $price;
    
    ?>
    
     ?>

    This code should work, ignore my first please :)

  9. RapBatLe
    Member
    Posted 1 year ago #

    hmmmm thanks i tested your code, it's look pretty but in if you get false and all code is execute in "else" i put in else echo"don't work" and see result, we can modify condition in if instruction?

    image

  10. RapBatLe
    Member
    Posted 1 year ago #

    thanks i love you :D

    i modified condition in if, like this:

    <?php
    /**
     * Loop Price
     */
    
    global $woocommerce, $product;
    ?>
    
    <?php
    
    if ($product->sale_price) :
    					$price .= '<span class="price">'.woocommerce_price( $product->regular_price ).'</span> <span class="price2">'.woocommerce_price( $product->sale_price ).'</span>';
    					$price = apply_filters('woocommerce_sale_price_html', $price, $this);
    				else :
    					$price .= '<span class="price">' .woocommerce_price( $product->price ).'</span>';
    					$price = apply_filters('woocommerce_price_html', $price, $this);
    				endif;
    echo $price;
    
    ?>
  11. samueljeden
    Member
    Posted 1 year ago #

    @RapBatLe

    Did this work for you then? I posted after a VERRRRRRY LONG day, and probably wasnt thinking straight ha..

    Thanks :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic