yf_shop__basket_save user module

Fileplugins/shop/modules/shop/yf_shop__basket_save.class.php
Usemodule('shop__basket_save'), URL ?object=shop__basket_save

Public properties

PropertyDefaultDescription
None declared in this class.

Public methods 1

None without a leading underscore.

Methods starting with _ hooks and helpers; not routable as page actions

_basket_save

public function _basket_save()

Save basket.

    public function _basket_save()
    {
        if ( ! empty($_POST['quantity']) && ! module('shop')->_basket_is_processed) {
            module('shop')->_basket_api()->clean();
            $products_ids = [];
            foreach ((array) ($_POST['quantity'] ?? null) as $_product_id => $_quantity) {
                $_product_id = (int) $_product_id;
                $_quantity = (int) $_quantity;
                if ($_product_id && $_quantity) {
                    module('shop')->_basket_api()->set($_product_id, [
                        'product_id' => $_product_id,
                        'quantity' => $_quantity,
                        'atts' => ($_POST['atts'][$_product_id] ?? null),
                    ]);
                }
            }
            // Prevent double processing
            module('shop')->_basket_is_processed = true;
        }
    }