Calculated Lengths and Weights not reaching shipping calculations
-
Hi there.
I ran into another issue, sorry…
If the plugin took its dimensions and weight from cart data instead of product data, it would be more-compatible with Woocommerce and the various plugins that might need to alter dimensions and weight (such as if someone was wanting to order 10 feet if steel beam, 12 cu yards of dirt, 2 tons of gravel, etc…)
For example:
accessing woocommerce_get_item_data to grab
$cart_item['data']->get_weight()
in WC_Shipping_RLC.php it appears to instead be reaching back to product data for this.
public function add_package_items_to_request($package, &$request) { $contents = $package['contents']; foreach ( $contents as $key => $item ) { $id = intval($item['variation_id'])?$item['variation_id']:$item['product_id']; $_pf = new WC_Product_Factory(); $product = $_pf->get_product($id); $request['items'][$key] = array( 'product_id' => $item['product_id'], 'variation_id' => $item['variation_id'], 'quantity' => $item['quantity'], 'origin' => array_key_exists('origin', $package)?$package['origin']:null, 'class' => wc_rlc_get_item_shipping_class($id, $package, $this), 'weight' => $product->get_weight(), 'is_hazmat' => wc_rlc_is_product_hazmat($id), 'length' => $product->get_length(), 'width' => $product->get_width(), 'height'=> $product->get_height() ); } }
Knowing the plugin better than I do, is there a quick and simple hook you could recommend for this? I would say that this sort of enhancement as a permanent change could make the plugin play better with others.
- The topic ‘Calculated Lengths and Weights not reaching shipping calculations’ is closed to new replies.