Woocommerce Adding price amount class ("woocommerce-Price-amount amount) to return $price
I am building a measurement Store with Woo and need some special Outputs for Pricing I am not able to fix.
The Price Output needs to be:
Price per Package and the Price per Unit so I need to add the class="woocommerce-Price-amount amount" for Display
1) I had used this Snippet to Display the Unit of Package Price:
function cw_change_product_price_display( $price ) {
$price .= ' per package';
return $price;
}
add_filter( 'woocommerce_get_price_html', 'cw_change_product_price_display' );
add_filter( 'woocommerce_checkout_cart_item_quantity', 'wb_checkout_review', 10, 3 );
2) And tried these to adding the woo Price Amount, resulting into crashing.
add_filter( 'woocommerce_get_price_html', 'wb_change_product_html' );
function wb_change_product_html( $price ) {
$price_html = <span class="woocommerce-Price-amount amount"> ' . $price . ' per m² </span> ;
return $price_html;
}
I Cant find a $price amount var. or table so I don't know how to fix these. I hope someone is able to help me with these to fix.
Thanks a lot
Solutions
I got it with adding an shortcode:
function cw_change_product_price_display( $price ) {
$price .= ' per Package';
echo do_shortcode('[your Shortcode]');
return $price;
}
add_filter( 'woocommerce_get_price_html', 'cw_change_product_price_display' );
Similar questions
WooCommerce Measurement Price Calc - replace price range by min price
Hopefully the title is fairly self explanatory! I'm using Measurement Price Calculator (MPC) in WooCommerce here. I have added the tweak in my functions.php to alter the price display on variable products so that it hides the from - to price range and just shows "from {lowest price}". I believe this is a fairly common tweak users make in WooCommerc...
How to change "Return to
[email protected]
" to "Return to Seller's Business Name" in Woocommerce?
I'm using Woocommerce for my current project. Everything is okay. But, when a customer purchases and makes payment through PayPal, PayPal shows messages with Seller's email address. Example: Before payment:http://i.stack.imgur.com/fk78l.png After payment http://i.stack.imgur.com/h252d.png Is there anybody to help?
Do I need to instantiate the XMLRPC class or any class in another class to access its methods?
I would like to use some of the methods of the XML RPC class, "wp_xmlrpc_server" in my own class. Is this class instantiated already or should I declare it myself? If so how?
PHP "Fatal Error: Class not found" when trying to instantiate class that extends a class from another file. Wordpress, but not specific to
This question is particular to wordpress, but I don't believe it is a wordpress specific question. I am getting a class not found error when I try to create a new object of type "sample_widget". The code is below: Results in this: Fatal error: Class 'sample_widget' not found in /my file I have created another base class, and derived from it, in the...
If div has class remove class or else add a new class
I have a '-' button on my WordPress website that I want to use to add a class to the <body> of my page to increase font size. I also have a '+' button, which will decrease the size of font. Plus button HTML: <div class="biggerTextButton"><p>+</p></div> Minus button HTML: <div class="smallerTextButton"><p>-&...
Adding class to menu_class to wp_nav_menu adds class to div instead of ul
I am very new to wordpress themeing . I am trying to create a Twitter Bootstrap menu to my newly created theme as below in header.php page. With the above codes, I am expecting to add a class to navbar-collapse collapse to ul, but instead it produces HTML as below : <div class="navbar-collapse collapse"><ul><li class="page_item page-...