Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter RapBatLe

    (@rapbatle)

    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>

    Thread Starter RapBatLe

    (@rapbatle)

    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

    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?

    Thread Starter RapBatLe

    (@rapbatle)

    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

    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;

    Something like that could possibly work?

    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 🙂

    Thread Starter RapBatLe

    (@rapbatle)

    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

    Thread Starter RapBatLe

    (@rapbatle)

    thanks i love you 😀

    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;
    
    ?>

    @rapbatle

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

    Thanks 🙂

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Price’ is closed to new replies.