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
- Getting the gallery images from products in woocommerce?
- add_filter to modify woocommerce_cart_item_name hyperlink
- 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?
- Programmatically change Payment Methods WooCommerce
- pre_get_posts with WooCommerce Shortcode Query
- How to add product images using script?
- How to update variable product stock status with code
- Woocommerce Product Image and Thumbnails custom function
- Create WooCommerce new order with specific ID
- woocommerce change order statuses count for specific role
- is_user_logged_in() always returns false for woocommerce_login_redirect
- Updating Existed RocketTheme Theme on WordPress
- WordPress ‘on behalf of’ email
- Display description on cart page
- Which hook should I use to capture $_POST(‘password’) via profile update and password reset
- How to change a column width on WooCommerce orders page (Admin)
- display first sale product in shop
- changing meta value and meta key of price field
- Problems adding in-store product managers
- How to select from two different tables to display orders list with custom column from other table
- Keep getting Notice: Trying to get property of non-object in …\wp-includes\post.php on line 4153 when generating woocommerce coupon
- How to subscribe free subscription on user registration in woocommerce subscription plugin?
- WooCommerce Product URL re-writing
- Woocommerce cart page – Add “Free” to the shipping label when shipping is 0
- Change product in cart when billing country is changed
- Calculate tax on sales price excluding discount [closed]
- How to override the title tag for woocommerce endpoints?
- WooCommerce – Global $product is returning value null
- How to re-arrange this hooked content?
- Pre filter woocommerce products to remove a certain category of products
- WooCommerce Stripe Plugin not showing up in settings [closed]
- Remove “?add-to-cart=product-id” from Add to Cart URL when on the Cart page
- WooCommerce plaintext mail doesn’t display currency symbol
- Woocommerce, finding the ordinal number of a purchase for a certain product
- WooCommerce order refund get qty refunded
- WooCommerce add_to_cart
- Add custom body tag if product is out of stock
- Woocommerce replace product page image with product tabs [closed]
- wordpress shortcode not working
- Multiple Pricing [closed]
- How to get all customers cart from woocommerce API?
- WooCommerce login redirect based on cart
- Adding product on sale into specific category after creation
- call_user_func_array() expects parameter 1 to be a valid callback, class ‘WC_Rapyd’ does not have a method ‘install’
- Conditional for product attribute page
- Setting Page Visibility for WooCommerce Default Page Doesn’t Work
- Deleted products from woocommerce are still in the database
- Remove cart functionality from WooCommerce so it doesn’t remember the products [closed]
- Apply CSS to certain product thumbnails only
- Order Woocommerce Products by On Sale and Alphabetically
- How to track product price changes?
- Woocommerce Flexslider touch functionality on desktop not working
- Customer Email Address
- How to echo woocomerce attributes values in dropdown box
- Add new page in WooCommerce My Account page
- Adding time of order to Admin email for new order
- Woocommerce list variations that are added already to cart in Single Product
- Uninitialised Parameters using woocommerce_checkout_update_order_meta hook
- Woocommerce customer role doesn’t change if user is already a subscriber [closed]
- Hide add to cart when product variation has no price or is unavailable
- get_posts only getting most recent product
- How to get the WooCommercer product variation image
- how add css class to product boxes li, for img, add cart button, decs, price… [closed]
- After WooCommerce-Update fucntion not working anymore
- How can I hide the entire “Shipping Details” block on the admin side of Woocommerce? [closed]
- Decrease stock quantity when a variation is sold using Woocommerce
- WooCommerce show decimals in totals [closed]
- I want to update shipping charge $0 for all Woocommeerce Subscription auto-renewal orders
- Conflict between Woocommerce Booking + Woocommerce Product Options [closed]