Well, the problem is you are calling price
directly at $value['data']->price
. Make it $value['data']->get_price()
and I think you problem will be fixed. So the whole code block will be-
function calculate_embossing_fee( $cart_object ) {
if( !WC()->session->__isset( "reload_checkout" )) {
/* Gift wrap price */
$additionalPrice = 5;
foreach ( $cart_object->cart_contents as $key => $value ) {
if( isset( $value["embossing_fee"] ) ) {
// Turn $value['data']->price in to $value['data']->get_price()
$orgPrice = floatval( $value['data']->get_price() );
$discPrice = $orgPrice + $additionalPrice;
$value['data']->set_price($discPrice);
}
}
}
}
add_action( 'woocommerce_before_calculate_totals', 'calculate_embossing_fee', 99 );
Hope that helps.
Related Posts:
- Display single product attribute value on Shop page (Woocommerce)
- Get product details by url key in WordPress woocommerce
- Where is the “default attribute” values located in the phpMyAdmin in Woocommerce?
- Extend Woocommerce rest api routes fails
- How to get all attributes with their terms related to specific Woocommerce product category [closed]
- Is WooCommerce updates for WordPress necessary? [closed]
- Remove “Choose An Option” on Product Variation & Auto Select Instead
- why featured product not updated in postmeta table in woocommerce?
- Programmatically adding product attributes to WP / Woo commerce
- Woocommerce custom search
- Get product variation attribute titles – WooCommerce
- How to change Attribute Type
- WooCommerce – buying as well as selling
- Is it possible to merge Woocommerce attributes? [closed]
- Redirect to another page using contact form 7? [closed]
- Best Practice – Customise a WooCommerce+WordPress Templates
- WooCommerce: One term for Many Product Attributes
- How to remove product attribute row woocommerce using code
- WooCommerce Simple Product Options List
- Protecting WooCommerce Customizations with Update
- Woocommerce: Any way to list all products *without* a specific attribute?
- How to add product variations for large number of products in WooCommerce?
- WooCommerce: how to set stock per attribute on variable product
- Is it safe to update an old site after backing it up and activating a child theme?
- Importing Attributes in to Woocommerce
- Woocommerce: Some action hooks not firing inside class [closed]
- Is it possible Different templates of products for specific category in WooCommerce?
- WooCommerce – Adding Product Attributes to CSV Export
- WordPress and WooCommerce How to Assign Attribute Based Pricing
- Create templates from attributes for categories
- What is your best practice to execute one-time scripts?
- Woocommerce – Add a product to cart programmatically via JS or PHP [closed]
- ( Woocommerce) How to get the user belonging to an order? [closed]
- Get the product list of a given Category ID
- List of JS events in the WooCommerce frontend
- get woocommerce My account page link
- Customizing a WordPress theme without changing it?
- WooCommerce: How to edit the get_price_html
- Get woocommerce product price by id [closed]
- Product categories don’t appear as option to build menu
- WooCommerce Variable Product Price not showing on single product page
- Plugin SVN & update API – how are plugins identified?
- How to override WooCommerce template files?
- Woocommerce add extra field to variation product
- Getting the gallery images from products in woocommerce?
- How to get current product category ID in product archive page
- Get url of product’s images (woocommerce)
- WooCommerce prices location in DB
- Order by rating not works in wp_query
- how to override woocommerce specific loop or archive-product.php [closed]
- Woocommerce: How to remove page-title at the home/shop page but not category pages
- Woocommerce show cross sells on singe product page [closed]
- How to add a new endpoint in woocommerce
- Are there any hook or filter when refund is done through admin -woocommerce
- How to check if is in cart page? [closed]
- WP/WooCommerce REST API cart/checkout/order [closed]
- how to use wc_create_order with subscription product
- WooCommerce: Webhook disabled on its own
- Get all products with a custom attribute
- Woocommerce add to simple product attribute programmatically [closed]
- Upgrading WordPress and Plugins; any Tips to Avoid Trouble?
- Share users and WooCommerce memberships between two installations
- Slow Loading Attribute Select – WooCommerce Backend
- WooCommerce: Can’t use wc_get_products for custom REST API endpoints
- How to change or add Woocommerce thank you page URL key content?
- Why is Google Webmaster Tools telling me to update WordPress
- How can I define a custom template for woocommerce [products] shortcode? [closed]
- How to remove an action within a class with extends
- single-product.php template not working for single products [closed]
- Insert variations via woocommerce api [closed]
- How to force function to run as the last one when saving the post?
- WooCommerce get physical store address
- Is it possible to add custom fields to a WooCommerce attribute term? [closed]
- wc_get_template_part( ‘content’, ‘product’ ) | Where is this file located?
- Creating custom Woocommerce attribute taxonomies from a plugin
- how to get woocommerce product attribute slug
- Correct function to get the user’s latest Woocommerce Subscription?
- Move payment options at checkout in WooCommerce [closed]
- add_filter to modify woocommerce_cart_item_name hyperlink
- Where do the cart details are stored in database?
- How to display product price of the product in loop
- How to disable Woocommerce password recovery and use the default WordPress password reset page?
- Display order items names in WooCommerce admin orders list [closed]
- Is it safe to delete from db orphaned posts i.e. whose post_parent no longer exists?
- Add custom variable to cart content [closed]
- Get product link
- WooCommerce – Hook after Loading Variation in Admin Edit page?
- How to delete woo commerce order pragmatically? [closed]
- WooCommerce changes lost password reset link
- Process checkout using WC REST API
- How to get rid of the hover zoom in WooCommerce single products
- How do I display certain products via their category on a section of a page using PHP?
- How to turn off WooCommerce user registration and manually create accounts?
- What’s the difference between WC() and $woocommerce
- Display orders instead of woocommerce my account dashboard for logged in users [closed]
- Limit users to one active subscription in WooCommerce Subscriptions? [closed]
- Detect whether a page is a product subcategory page?
- How to override wp-login.php
- Hidden woocommerce products still showing up in search results [closed]
- Menu not show woocommerce product category