function basic_cart_entity_presave in Basic cart 8.4
Same name and namespace in other branches
- 8.6 basic_cart.module \basic_cart_entity_presave()
- 8 basic_cart.module \basic_cart_entity_presave()
- 8.0 basic_cart.module \basic_cart_entity_presave()
- 8.2 basic_cart.module \basic_cart_entity_presave()
- 8.3 basic_cart.module \basic_cart_entity_presave()
- 8.5 basic_cart.module \basic_cart_entity_presave()
Implements hook_entity_presave().
File
- ./
basic_cart.module, line 105 - Basic cart module file.
Code
function basic_cart_entity_presave(EntityInterface $node) {
if (Utility::isBasicCartOrder($node
->bundle())) {
$get_price = Utility::getTotalPrice();
$cart = Utility::getCart();
$content = $cart['cart'] ? $cart['cart'] : [];
if (empty($node
->id())) {
$node
->set('basic_cart_vat', $get_price->vat);
$node
->set('basic_cart_total_price', $get_price->total);
$node
->set('basic_cart_content', array_keys($content));
}
}
}