oc-shopaholic / oc-orders-shopaholic-plugin

🛒 Orders (cart) extension for Shopaholic plugin
https://octobercms.com/plugin/lovata-ordersshopaholic
GNU General Public License v3.0
27 stars 18 forks source link

OnRemove does not working with proterties #151

Open MariaMatvienko opened 3 years ago

MariaMatvienko commented 3 years ago

Hello I am having a problem. The request 'Cart::onRemove' does not remove an item from the cart if it has properties. I do it like this:

 let data = {
        'cart': [id_elem]
    };
    $.request('Cart::onRemove', {
        'data': data,
        update: { 'cart': '.cart_modal' }
    });

And I add like this:

 let data = {
            'cart': [
                { 'offer_id': id_offer.id, 'quantity': 1, 'property': { 'color': '111111' } }
            ]
        };
        $.request('Cart::onAdd', {
            'data': data,
            update: { 'cart': '.cart_modal' }
        });
wobqqq commented 3 years ago

@Meshtli In an ajax request, you need to send the id of the cart position.

igor-tv commented 3 years ago

@Meshtli In an ajax request, you need to send the id of the cart position.

Perhaps it is worth pointing out in the documentation? In the case of using additional properties of an order position, it is necessary to pass the position id and the "position" as a value of type to remove a position from the cart.

I don't see any other way to fix this bug. Only if you transfer, in addition to the offer id, an array with position properties, which is not very convenient in case of removal.