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

Add product to cart #171

Closed ricardsbe closed 2 years ago

ricardsbe commented 2 years ago

Hello! I am new at programming, and i want to know why my add to cart ajax function is not working.. AJAX : $('body').on('click', '.add-grozs', function (e) { var data = { 'cart': [ {'offer_id': 2, 'quantity': 4} ] };

$('body').on('click', '.add-grozs', function (e) { var data = { 'cart': [ {'offer_id': 2, 'quantity': 4} ] };

//Send ajax request and update cart items
$.request('Cart::onAdd', {
    'data': data,
    'update': {'grozs': '.cart'}
});

}); Html button:

        <button class="add-grozs">Add to cart</button>

Thanks!

kharanenka commented 2 years ago

Hi! What response form Cart component do you have?

ricardsbe commented 2 years ago

Thanks! I solved everything. Now i have another problem , i have addeed account page, everything is working fine, in account page name is showing of user, but how i can add a order field to show which orders client have made

kharanenka commented 2 years ago

Hi! You can find examples here

ricardsbe commented 2 years ago

Hi! It is showing fallowing error, when i am trying to add order page Type error: Too few arguments to function Lovata\OrdersShopaholic\Classes\Event\User\UserModelHandler::Lovata\OrdersShopaholic\Classes\Event\User{closure}(), 0 passed and exactly 1 expected

ricardsbe commented 2 years ago

Could you please help me?

kharanenka commented 2 years ago

Hi! Please send us full error log. Now it is difficult for me to understand what the error is. What user plugin are you using in your project?

ricardsbe commented 2 years ago

I an using buddies. Full eror screeen shot https://prnt.sc/26cf1qa

kharanenka commented 2 years ago

Try to change 158 line in plugins/lovata/ordersshopaholic/classes/event/user/UserModelHandler.php file from:

$obUserItem->addDynamicMethod('getOrderAttribute', function ($obUserItem) {

to

$obUserItem->addDynamicMethod('getOrderAttribute', function () use ($obUserItem) {
ricardsbe commented 2 years ago

Thanks! You helped me a lot! Now orders work!

ricardsbe commented 2 years ago

And one more question how to do auto fill when making order if client is logged in

kharanenka commented 2 years ago

It is default logic in Orders plugin. MakeOrder component gets loggined user and attaches it to new orders

ricardsbe commented 2 years ago

Ok, thanks!