• Resolved robstyrrell

    (@robstyrrell)


    WordPress: 6.5, WooCommerce: 8.7.0, Weight Based Shipping: 5.9.0, PHP: 7.4.

    https://imgur.com/a/5DE7mVM

    Hi,

    I’m having an issue with the weight. I’m using a plugin called Price by Formula Calculator for WooCommerce.

    The customer enters the width and length and the plugin calculates the price and weight based on the product.

    The correct weight is showing both in the cart and at checkout, however, the WooCommerce Weight Based Shipping plugin is not using that weight.
    Instead, it is simply multiplying the quantity ordered by the product weight. This is incorrect. Should your plugin not use the cart weight?

    I’ve checked with the other plugin developers and they said this:

    As our module sets the correct weight of the product in the cart and checkout page. But you are using some third party plugin that is dealing with shipping, maybe they are not getting the weight from the cart item. So we recommend you to please contact that plugin support. Maybe they can better help and guide you about this issue. We hope you will understand. Thank you for your cooperation.

    Hoping you can help!

    Thanks,
    Rob

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Dan

    (@dangoodman)

    Hi Rob,

    It would be great if you could invite the calculator plugin devs to this thread to share their thoughts and the technical details of their implementation.

    The default WooCommerce data model includes the following concepts:
    – cart item quantity,
    – product weight.

    The WooCommerce order data model does not have fields for ‘cart item weight’ or ‘total cart weight’. The default approach (and that is how WooCommerce works) is to multiply product weight by cart item quantity and add this up for every line in the cart to form the total order weight.

    Since there is no standard everybody agrees upon to override those, plugins cannot integrate automatically. I would be glad to hear if there is an unofficial convention, though.

    Thread Starter robstyrrell

    (@robstyrrell)

    Hi Dan,

    Thanks for your response. How do I invite them?

    Thanks,
    Rob

    Thread Starter robstyrrell

    (@robstyrrell)

    Hi,

    I’ve passed on your comments to the developer and they said this:

    Hi there,

    We hope you are doing well.

    Please ask third-party developers to use the following methods to get the weight of the product:

    $product = $cart_item[‘data’];
    $weight = $product->get_weight()

    OR

    $changes_made_in_cart=$cart_item[‘data’]->get_changes();
    $weight=$latest_weight=$changes_made_in_cart[‘weight’];

    OR

    $weight=$latest_weight=$cart_item[‘plugify_shipping_weight’];

    We can’t make changes in third-party plugin code because we don’t know where or how they are getting the weight, so they can better assist you. Thank you so much for your continued cooperation.

    Best Regards
    Plugify Support Team

    Does that help?
    Rob

    Plugin Author Dan

    (@dangoodman)

    $product = $cart_item[‘data’];
    $weight = $product->get_weight()

    That is how WBS gets the weight.

    Thread Starter robstyrrell

    (@robstyrrell)

    Hi Dan,

    To add a bit more weirdness to this, if I clear WooCommerce transients then your plugin shows the correct price for shipping.

    Any idea why this might be?

    Thanks,
    Rob

    Plugin Author Dan

    (@dangoodman)

    Hi Rob,

    What happens if you enable the WooCommerce Shipping Debug mode to turn off the shipping cache? Do you see the same (correct) results as when clearing the transients manually?

    Thread Starter robstyrrell

    (@robstyrrell)

    Hi Dan,

    Yes, if I enable shipping debug mode then the correct shipping costs are shown.

    Thanks,
    Rob

    Plugin Author Dan

    (@dangoodman)

    That means the custom weight substituted by Price by Formula plugin is applied after the shipping calculations took place and cached by WooCommerce. The solution would be to update the Price by Formula plugin to a) substitute the weight earlier, before WooCommerce triggers shipping calculations, or b) reset the shipping cache after the substitution.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Weight calculated incorrectly’ is closed to new replies.