Im currently using a plugin to prepend the word "from" before some of my onsite prices, but im trying to hardcode this so i can remove the plugin as it slows down my site. I feel like im close, but ive looked everywhere and cant seem to find how to prepend an advanced custom field on the price field.
The code im using in my functions is
/**
* Display before_price custom field on frontend test (kinda working)
* @since 1.0.0
*/
add_action( 'woocommerce_single_product_summary', 'shoptimizer_before_price', 10 );
function shoptimizer_before_price($price) { ?>
<?php if(get_field('before_price')) { ?>
<div class="cg-before_price"><?php the_field('before_price'); ?></div>
<?php }
}
but as you can see on this page, its displayed after the price instead of before. any pointers please team?
https://www.subscriptionboxaustralia.com/product/beauty-subscription-boxes/boxy-charm-storks/
Thanks
2
Answers
PHP Snippet: Add Prefix to WooCommerce Prices
Reference: https://www.businessbloomer.com/woocommerce-add-prefix-suffix-product-prices/
I had a similar problem. Maybe this will help:
Reference: https://bloginbox.com/how-to-add-prefix-and-suffix-to-woocommerce-prices/