• Resolved Sjoerd

    (@sjoerd16)


    I just altered the woocommerce price html to show the price per unit (add html on the end of the price html).

    When pricing rules are active (graduated discount) the price html gets overwritten / the price per unit disappears. How to add this to the end of the price string when pricing rules are active? Below is the code I used

    function dd_change_product_html( $price_html, $product ) {
    	if($product->price > 0){
    		 $bundelditems = $product->get_nbbundleditems();
    		 if($bundelditems != null){
    			 $perunit = $product->price / $bundelditems;
    			 $price_html .= '<p class="unitprice"><span>'.number_format($perunit, 2, ',', '').' p/st</span></p>';
    		 }
     	}
     	return $price_html;
    }
    add_filter( 'woocommerce_get_price_html', 'dd_change_product_html', 10, 2 );
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Add html after price’ is closed to new replies.