Discussions
Bugs in WooCommerce Plugin
about 23 hours ago by Roland
Hi,
You have 2 bugs in your WooCommerce plugin.
- The weight_to_kg function is converting kilograms to grams, and not the other way around. This is due to an incorrect comparison operand
if ( 'g' !== $weight_unit ) { // <-- this should be 'g' === $weight_unit
$weight = $weight * 0.001;
} elseif ( 'lbs' === $weight_unit ) {
$weight = $weight * 0.453592;
} elseif ( 'oz' === $weight_unit ) {
$weight = $weight * 0.0283495;
}
- Then, in your
calculate_shipping
function, you are using the product dimensions and weight to calculate the shipping cost instead of using the cart items values. Certain plugins or custom implementations can programmatically change these values for cart items, but the cost is always calculated with the static values set in the backend.
In class-easyship-shipping-method.php
, replace the $product
variable with $item['data']
on likes 395-398.
$items[] = array(
'actual_weight' => $this->weight_to_kg( $item['data']->get_weight() ),
'height' => $this->default_dimension( $this->dimension_to_cm( $item['data']->get_height() ) ),
'width' => $this->default_dimension( $this->dimension_to_cm( $item['data']->get_width() ) ),
'length' => $this->default_dimension( $this->dimension_to_cm( $item['data']->get_length() ) ),
Please let me know if these changes will be implemented in the next update :)
Thanks!