Support

Account

Home Forums General Issues Calculations in Woocommerce shopping cart

Unread

Calculations in Woocommerce shopping cart

  • I am using ACF together with Woocommerce, and I would like to add some extra calculations to my shopping cart, based on values typed in the extra custom field for each product.
    So my field is called donation, and it is different for each product.
    In shopping cart I’d like to show the total donation based on the products in a cart.

    I tried something like this to test it:

    <?php
    global $woocommerce;
    $donation = floatval(get_field(‘donation’));
    echo $donation;
    ?>

    But it throws ‘0’ even when there is only on eproduct in the cart. How can I hook the ‘donation’ field to sum up all ‘donation’ fields for each product in the cart?

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.