Hooks
You can attach hooks to various places in the lifecyle of various processes in Padloper. Perhaps most important is being able to attach hooks during the checkout process.
Price Hook
You can amend the price of any product during checkout by using a hook like shown below.
namespace ProcessWire;
$this->addHookAfter('PadloperCart::getProductPrice', null, 'customProductPrice');
function customProductPrice(HookEvent $event) {
$product = $event->arguments('product');
// get the product field with the price
$stock = $product->padloper_product_stock;
// grab the price
$price = (float) $stock->price;
# amend price if condition is met
if (wire('user')->name ==='my_best_friend') {
$price = 0.01 * $price;
}
$event->return = $price;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
More Hooks: TBD