Hi I'm having a problem displaying a "You Save" figure in my product page. If a user is logged out it shows correctly "You Save: £xx (xx%)". It also shows correctly if a user is logged in and there are no prices entered in the b2b king price tiers for the various user groups and just the "regular price" / "Sale Price" are filled.
Currently the site is set without prices in the various tiers for logged in users, so please note you will be able to see the calculation working as intended
Below is the code snippet I'm using to display the discount amount string. Please could you have a look and let me know what I need to do to make the calculation work when a price is entered into a B2BKing price tier. Thanks
// For simple products add_action( 'woocommerce_single_product_summary', 'simple_product_saving_amount', 11 ); function simple_product_saving_amount() { global $product;
1) For customer support, kindly please provide us with your purchase code for the plugin. To get the code, you can go to https://codecanyon.net/downloads -> Click as it's shown in this image:
-> The text file downloaded should have something like this inside: Item Purchase Code: b3e5fe72-00b0-4019-a8e2-06fb26264742
Thank you for the help,
2)
What exactly happens when you add the price tiers?
Does the "You Save" figure not display at all? Or does it display but the calculation is incorrect?
Thanks for the reply. I don't have a purchase code for the plugin, I downloaded it straight from my wordpress plugins module. Isn't 'product pre-orders for woocommerce' a free plugin?
To answer your question no.2, when the price tiers are added the "you save" displays except the price/ percentage calculation is just 0
That code works perfectly!! Thank you so much for your work on it!! PS. B2BKing is a great product by the way, easy to use yet powerful enough to handle a variety of complex setups. Brilliant work!
Hi I'm having a problem displaying a "You Save" figure in my product page. If a user is logged out it shows correctly "You Save: £xx (xx%)". It also shows correctly if a user is logged in and there are no prices entered in the b2b king price tiers for the various user groups and just the "regular price" / "Sale Price" are filled.
Currently the site is set without prices in the various tiers for logged in users, so please note you will be able to see the calculation working as intended
Below is the code snippet I'm using to display the discount amount string. Please could you have a look and let me know what I need to do to make the calculation work when a price is entered into a B2BKing price tier. Thanks
// For simple products
add_action( 'woocommerce_single_product_summary', 'simple_product_saving_amount', 11 );
function simple_product_saving_amount() {
global $product;
if( $product->is_type('simple') && $product->is_on_sale() ) {
$regular_price = (float) wc_get_price_to_display( $product, array('price' => $product->get_regular_price() ) );
$active_price = (float) wc_get_price_to_display( $product, array('price' => $product->get_sale_price() ) );
$saved_amount = $regular_price - $active_price;
$percentage = round( $saved_amount / $regular_price * 100 );
echo '<p id="saving_total_price">'. __("You Save") .': ' . wc_price($saved_amount) . ' ('.$percentage.'%)</p>';
}
}
// For product variations (on variable products)
add_filter( 'woocommerce_available_variation', 'variable_product_saving_amount', 9999, 3 );
function variable_product_saving_amount( $data, $product, $variation ) {
if( $variation->is_on_sale() ) {
$saved_amount = $data['display_regular_price'] - $data['display_price'];
$percentage = round( $saved_amount / $data['display_regular_price'] * 100 );
$data['price_html'] .= '<p id="saving_total_price">'. __("You Save") .': ' . wc_price($saved_amount) . ' ('.$percentage.'%)</p>';
}
return $data;
}
HI Tim,
Thanks for using our plugins,
1) For customer support, kindly please provide us with your purchase code for the plugin. To get the code, you can go to https://codecanyon.net/downloads -> Click as it's shown in this image:
-> The text file downloaded should have something like this inside: Item Purchase Code: b3e5fe72-00b0-4019-a8e2-06fb26264742
Thank you for the help,
2)
What exactly happens when you add the price tiers?
Does the "You Save" figure not display at all? Or does it display but the calculation is incorrect?
Kind regards,
Stefan
Hi Stefan,
Thanks for the reply.
I don't have a purchase code for the plugin, I downloaded it straight from my wordpress plugins module. Isn't 'product pre-orders for woocommerce' a free plugin?
To answer your question no.2, when the price tiers are added the "you save" displays except the price/ percentage calculation is just 0
Hi Tim,
"product pre-orders for woocommerce" is not our plugin. Our plugin is B2BKing. There is indeed a free version of the plugin here https://wordpress.org/plugins/b2bking-wholesale-for-woocommerce/
This support forum here is for the premium version of the plugin.
The support forum for the free version is available at https://wordpress.org/support/plugin/b2bking-wholesale-for-woocommerce/
However there is no "Price tiers" functionality in the free version - that is only a premium feature.
Kind regards,
Stefan
No worries, now it all makes sense! Thank you for sharing the purchase code,
Please try to replace your current snippet with the following:
Hi Stefan,
That code works perfectly!! Thank you so much for your work on it!!
PS. B2BKing is a great product by the way, easy to use yet powerful enough to handle a variety of complex setups. Brilliant work!
Thanks again,
Tim
Glad to hear that worked, and thank you for the kind words!