ittspiritgr
Forum Replies Created
-
Forum: Plugins
In reply to: [WooCommerce Product Fees] Product fee below price on product pageFor your convenience, all the strings I am echoing are translation ready as I use the following call:
__( string $text, string $domain = 'default' )
Forum: Plugins
In reply to: [WooCommerce Product Fees] Product fee below price on product pageYou can at will add in your echo statement the html code you wish. Don’t forget to use ‘.’ as string concatenation operator. For instance, the code below shows the one-time charges wrapped in a div and shows in bold the title (+ One Time Charges (excl. VAT):):
echo '<div><strong>' . __('+ One Time Charges (excl. VAT):', 'Your Domain') . ' </strong>' . wc_price($flat_fee) . '</div>;
- This reply was modified 6 years, 8 months ago by ittspiritgr.
Forum: Plugins
In reply to: [WooCommerce Product Fees] Product fee below price on product pageIf your fees are fixed (do not vary) for each one of your products you can inject additional details in any part for the product page.
For instance you can show your fees below the product title and price part as follows:add_action( 'woocommerce_single_product_summary', 'show_additional_product_details', 20 ); function show_additional_product_details() { global $product; if ( is_product() ) { $flat_fee = get_post_meta( $product->get_id(), 'product-fee-amount', true ); if ( !empty( $flat_fee ) ) { echo __('+ One Time Charges (excl. VAT):', 'Your Domain') . ' ' . wc_price($flat_fee); } } }
Forum: Plugins
In reply to: [WooCommerce Product Fees] Product fee below price on product pageYou seem to use some kind of volume/bulk discount plugin. Perhalps the plugin overwrites the woocommerce_get_price_html filter.
I suggest to try to disable volume/bulk discount functionality and check if the code is working.
Also check your other plugins to varify that they do not override the woocommerce_get_price_html filter.
Note: The code I wrote above is applicable to fees that are used as one-time-charges.Forum: Plugins
In reply to: [WooCommerce Product Fees] Product fee below price on product pageIf you wish to show the flat fee amount below the unit price and only for simple products here is the code:
function change_simple_product_price_display( $price_html, $product ) { if ( is_product() ) { if ( $product->is_type( 'simple' ) ) { $flat_fee = get_post_meta( $product->get_id(), 'product-fee-amount', true ); if ( ! empty( $flat_fee ) ) { $price_html = $price_html . '<br>' . __('+ One Time Charges (excl. VAT):', 'Your Domain') . ' ' . wc_price($flat_fee); } } } return $price_html; } add_filter( 'woocommerce_get_price_html', 'change_simple_product_price_display', 10, 2 );
If you wish to show the flat fee for all your products, then you need to remove the if ( $product->is_type( ‘simple’ ) ) part of the code.
- This reply was modified 6 years, 8 months ago by ittspiritgr.
- This reply was modified 6 years, 8 months ago by ittspiritgr.