Home › Forums › WoodMart support forum › About the presentation of price
About the presentation of price
- This topic has 9 replies, 2 voices, and was last updated 3 weeks, 6 days ago by Aizaz Imtiaz Awan.
-
AuthorPosts
-
October 16, 2024 at 3:16 am #605282
zhufan122881ParticipantHello
1、How can I make the original price font smaller than the discounted price?
2、Is there a way to display how much money is saved in WooCommerce?
Thank you!Attachments:
You must be logged in to view attached files.October 16, 2024 at 4:00 pm #605481
Aizaz Imtiaz AwanKeymasterHello,
01. Can you please share the page URL so I can check and give you a possible solution?
02. Try to add the following PHP code in the function.php of the child theme.
add_filter( 'woocommerce_get_price_html', 'change_displayed_sale_price_html', 10, 2 ); function change_displayed_sale_price_html( $price, $product ) { // Only on sale products on frontend and excluding min/max price on variable products if( $product->is_on_sale() && ! is_admin() && ! $product->is_type('variable')){ // Get product prices $regular_price = (float) $product->get_regular_price(); // Regular price $sale_price = (float) $product->get_price(); // Active price (the "Sale price" when on-sale) // "Saving Percentage" calculation and formatting $precision = 1; // Max number of decimals $saving_percentage = round( 100 - ( $sale_price / $regular_price * 100 ), 1 ) . '%'; // Append to the formated html price $price .= sprintf( __('<p class="saved-sale">You Save: %s</p>', 'woocommerce' ), $saving_percentage ); } return $price; }
Best Regards
October 16, 2024 at 4:42 pm #605504
zhufan122881Participant1、Actually this is another Theme, my friend told me. However, I did not use this theme because I think your theme is better, and it can be even more better.
https://themeforest.net/item/motta-multivendor-and-marketplace-wordpress-theme/47722442October 16, 2024 at 5:18 pm #605527
zhufan122881Participant2、I used this code. it works!
But the numbers I want to show are monetary savings figures.
Like : You Save: $99.00.
And, this number is in red. I don’t know if it’s possible?
Thank You!Attachments:
You must be logged in to view attached files.October 16, 2024 at 7:26 pm #605568
zhufan122881Participant2、In addition, I hope to adjust the font size of the regular price and not display the extra “you save” in the product archive.
You can check my website for details.
The account number and password are in the private message.
Thank youOctober 17, 2024 at 12:53 pm #605751
Aizaz Imtiaz AwanKeymasterHello,
Remove the previous code and add the following PHP code in the function.php of the child theme.
add_filter( 'woocommerce_get_price_html', 'change_displayed_sale_price_html', 10, 2 ); function change_displayed_sale_price_html( $price, $product ) { // Only on sale products on frontend and excluding min/max price on variable products if( $product->is_on_sale() && ! is_admin() && ! $product->is_type('variable')) { // Get product prices $regular_price = (float) $product->get_regular_price(); // Regular price $sale_price = (float) $product->get_price(); // Active price (the "Sale price" when on-sale) // Calculate monetary savings $saving_amount = wc_price( $regular_price - $sale_price ); // Monetary saving // Append the savings in monetary form if ( is_product() ) { // Only show on single product page $price .= sprintf( __('<p class="saved-sale" style="color:red;">You Save: %s</p>', 'woocommerce' ), $saving_amount ); } } return $price; }
For the font adjustment, add the below Custom CSS code to Theme Settings > Custom CSS > Global Custom CSS.
.woocommerce div.product p.price del { font-size: 18px; /* Adjust the size here */ }
Best Regards
October 22, 2024 at 8:32 am #606647
zhufan122881ParticipantThank you for your reply.
I used the above code with some adjustments and finally achieved the effect as shown in Figure 1.
But a new problem emerged. The “you save” widget will appear elsewhere, which is not what I want. as shown in Figure 1、2.
I think there should be one more restriction, but obviously the name “single product” is not precise enough.
Because after I used this statement, the problem was not fixed.
if( is_product() && $product->is_on_sale() && ! is_admin() && ! $product->is_type(‘variable’)) {
How do I need to modify the code please?
Thank you!- This reply was modified 4 weeks, 1 day ago by zhufan122881.
- This reply was modified 4 weeks, 1 day ago by zhufan122881.
Attachments:
You must be logged in to view attached files.October 22, 2024 at 11:10 am #606697
Aizaz Imtiaz AwanKeymasterHello,
Can you please share the page URL so I will check and give you a possible solution?
Best Regards
October 22, 2024 at 5:37 pm #606877
zhufan122881ParticipantSure
wp-admin URL:https://365onsale.com/product/kidscleancar/- This reply was modified 4 weeks ago by zhufan122881.
October 23, 2024 at 8:53 am #606954
Aizaz Imtiaz AwanKeymasterHello,
Sorry to say such modification requires complicated Woocommerce code customization which is not covered by our support.
You need to find a third-party plugin to achieve more functionality that best suits you.
Hope you can understand!
Best Regards
-
AuthorPosts
- You must be logged in to create new topics. Login / Register