• Resolved simaooliveira

    (@simaooliveira)


    Hi! I’m using your plugin to do a quantity based discount. I want to pull the cart total, with the discount already applied, to a side script that generates legal documents. How can I go about doint this ? I’ve inspected WC()->cart to try to find the amounts of the discounts, or an already discounted value, but to no avail, and WC()->cart->get_cart_total() gives me the non discounted value.

    Is there a function or filter i should run?

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Hermann LAHAMI

    (@mano88)

    I’m sorry we don’t store any calculated data. I tried with wc_cart_totals_subtotal_html() and WC()->cart->get_cart_total() from a shortcode I wrote and it worked fine. I’m able to pull the subtotal including the discounts for items with bulk discounts added to the cart.

    I’m not sure which part is failing on your side…

    Thread Starter simaooliveira

    (@simaooliveira)

    Tried doing wc_cart_totals_subtotal_html() on a template and i get the undiscounted amount as well…

    Plugin Author Hermann LAHAMI

    (@mano88)

    Are you sure your code is being exectued after woocommerce calculated the totals?

    Thread Starter simaooliveira

    (@simaooliveira)

    You’re right, that was the issue. I did WC()->cart->calculate_totals(); and now i get the discounts available on the WC()->cart object. Thank you so much for your help!

    Plugin Author Hermann LAHAMI

    (@mano88)

    My pleasure.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Get cart total programmatically’ is closed to new replies.