• Resolved Marc Lacroix

    (@marcusig)


    Hi there,

    I’m using an other plugin which can affect the price of the product when added to the cart, but advanced-product-fields-for-woocommerce overrides previously made changes by using the product’s base price instead of the price set in the cart items.

    So in class-product-controller.php > public function adjust_cart_item_pricing($cart_obj) {,
    instead of doing

    $base = Helper::get_product_base_price($product);

    it should do

    $base = $item['data']->get_price();

    in order to keep the changes made by other plugins.

    It would be great if you’d consider changing that.

    Thanks,
    Marc.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Wombat Plugins

    (@maartenbelmans)

    Hi @marcusig

    Our Helper function is already using get_price() under the hood.

    Kind regards,
    Maarten

    Thread Starter Marc Lacroix

    (@marcusig)

    Hi Maarten,

    The helper function uses wc_get_price_including_tax or wc_get_price_excluding_tax, which gets the base price of the product as set in the admin, not the current price of the cart item, discarding any other possible changes made to the price in the cart.

    My suggestion is to use the price of the cart item, which is what the function is modifying, instead of the base price.

    The helper function gets the price with or without tax, but $item['data']->get_price(); already has the correct price applied, plus any modifications made by other plugins.

    Marc.

    Plugin Author Wombat Plugins

    (@maartenbelmans)

    Hi Marc,

    One reason we take the product base price is because formulas and percentage calculations happen on that price (as it is generally the same price as being displayed on the single-product page).

    What plugin are you using that modifies cart price?

    Thread Starter Marc Lacroix

    (@marcusig)

    What plugin are you using that modifies cart price?

    It’s a custom plugin. So I can change it to fit with your plugin, but the reason I’m posting is that if it happened to me, others could encounter the same issue, without the ability to change their code.

    One reason we take the product base price is because formulas and percentage calculations happen on that price

    Okay, that makes sense. I’ll update my code to be compatible with the current calculations (adding my other costs later), but I think it would be good for you to eventually consider using the base price for calculations, but adding the difference to the cart item’s price instead of reseting it.

    Thanks for the support, and have a nice day ??

    Marc.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘adjust cart item pricing overrides previous changes to the price’ is closed to new replies.