Don't show regular prices, when on Sale?
-
Is there a way to hide regular prices (in all categories except one) when they have got sale prices?
I am searching a solution via PHP, because now it is hidden via CSS, but the regular prices still can be shown in Google Search Snippets.
For the variations this change works:
if ( $this->get_price() !== '' ) { if ( $this->is_on_sale() ) { $price = apply_filters( 'woocommerce_variation_sale_price_html', '<del>' . wc_price( $display_regular_price ) . '</del> <ins>' . wc_price( $display_sale_price ) . '</ins>' . $this->get_price_suffix(), $this ); } elseif ( $this->get_price() > 0 ) { $price = apply_filters( 'woocommerce_variation_price_html', wc_price( $display_price ) . $this->get_price_suffix(), $this ); } else { $price = apply_filters( 'woocommerce_variation_free_price_html', __( 'Free!', 'woocommerce' ), $this ); } } else { $price = apply_filters( 'woocommerce_variation_empty_price_html', '', $this ); } return apply_filters( 'woocommerce_get_variation_price_html', $price, $this );
Changed to (you have to customize THIS-IS-MY-CATEGORY):
if ( $this->get_price() !== '' ) { if ( $this->is_on_sale() && has_term( 'THIS-IS-MY-CATEGORY', 'product_cat', $this ) ) { $price = apply_filters( 'woocommerce_variation_sale_price_html', '<del>' . wc_price( $display_regular_price ) . '</del> <ins>' . wc_price( $display_sale_price ) . '</ins>' . $this->get_price_suffix(), $this ); } elseif ( $this->is_on_sale() ) { $price = apply_filters( 'woocommerce_variation_sale_price_html', '<ins>' . wc_price( $display_sale_price ) . '</ins>' . $this->get_price_suffix(), $this ); } elseif ( $this->get_price() > 0 ) { $price = apply_filters( 'woocommerce_variation_price_html', wc_price( $display_price ) . $this->get_price_suffix(), $this ); } else { $price = apply_filters( 'woocommerce_variation_free_price_html', __( 'Free!', 'woocommerce' ), $this ); } } else { $price = apply_filters( 'woocommerce_variation_empty_price_html', '', $this ); } return apply_filters( 'woocommerce_get_variation_price_html', $price, $this );
- The topic ‘Don't show regular prices, when on Sale?’ is closed to new replies.