• Resolved awalford

    (@awalford)


    I know CPO works with simple products only. After all, CPO replaces the need for product variations. But I have a difficult problem with another plugin.

    I use two shipping plugins from PluginHive. The problem is they don’t use the weights and dims from the items in the cart but instead go back to the simple product values. So I have CPO setting up the correct dimensions and weight in the cart (I traced it out to see) from some option and NOV calculations, but the shipping plugins don’t use those values as they don’t expect them to be different than the base Product values. The plugins do handle Variations but in this case because of CPO I am using just a simple product.

    If there was a way to programmatically pick from a product variation given the value in a CPO Option Variable, or Non-Option Variable, then it would fix the issue.

    I know it is a long shot but thought I’d try!

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

    (@moomooagency)

    Hi,

    Basically, it would be much easier to update those shipping plugins and force them to pick dims/weight from the cart item. Believe me, it would be easier and the right way.

    Thread Starter awalford

    (@awalford)

    Thanks. I knew it was a long shot.

    The shipping vendor refuses to make changes either saying their approach is correct. So I will need to go a different route now.

    I do use CPO on other products in our store and have found it to be very useful. Thanks for the help and quick reply.

    Plugin Author moomooagency

    (@moomooagency)

    You are welcome!

    Honestly, it would be super easy fix for them. I know it because I did such modifications. Some shipping plugins already do this, like USPS, if I am not mistaken. Do not know why they refuse.

    Technically, each cart item is a set of data that includes the original product object under ‘data’ key. Uni CPO uses built-in methods available for product, like ‘set_weight’ to set custom weight dynamically and specifically for the product instance attached to the cart item. Now, shipping plugins have two options:

    1) those like your plugin probably get product ID from the cart item product instance (remember, it is available straight away under ‘data’ key?), then get original product data by using ‘wc_get_product’, and then they get actual data using built-in methods like ‘get_weight’ from the original product; plain logic is the following:
    – $product_id = $cart_item[‘data’]->get_id()
    – $product = wc_get_product($product_id)
    – $weight = $product->get_weight() <- the original weight!

    2) sorry, cannot help myself, I must say this ?? – some other and smarter plugins actually just use the product instance available along with the cart item; plain logic is the following:
    – $weight = $cart_item[‘data’]->get_weight() <- the original weight OR dynamically modified weight (if it actually was modified)!

    Yes, it is as simple as that! ??

    Plugin Author moomooagency

    (@moomooagency)

    BTW, join our FB group Builderius community ??

    Thread Starter awalford

    (@awalford)

    Yes, I suspect they are doing 1) instead of 2) which is unfortunate. This is their reasoning from their message:


    I understand your requirement. However, our plugin is designed to take Weight and Dimensions from actual WooCommerce Product Object. The plugin uses its own multiple product attributes for Rates and Label Generation and also we have custom addons such as (Add More Shipping Fields addon) which will add additional product features that use the same Product Object and attributes.

    It will not be possible for the plugin to fetch the details provided on the product page from a third-party plugin. Also, as of now, it will not be possible to provide with any hooks as the plugin uses the Product Object in multiple places while fetching rates and generating Shipping Label.`

    I am not sure why they said “get weight from the other plugin”, because all I suggested is they get the weight and dims from the cart product object.

    I could probably fix their plugins myself, but on the next update that fix would disappear of course (why I asked for a hook).

    Oh well.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Can a product variation be chosen?’ is closed to new replies.