Created
April 12, 2022 11:35
-
-
Save GreatPotato/31559b5d5ec6628ea0a64cd95850b120 to your computer and use it in GitHub Desktop.
Add event to customize product weight
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function total_weight() | |
{ | |
$result = $this->om('weight')*$this->quantity; | |
$extras = $this->get_extra_option_objects(); | |
foreach ($extras as $option) | |
$result += $option->weight*$this->quantity; | |
$weight_adjusted = Backend::$events->fire_event(['name' => 'shop:onGetOrderItemWeight', 'type'=>'filter'], $this); | |
return ($weight_adjusted) ? $weight_adjusted : $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment