Search the Community
Showing results for tags 'ajaxCart'.
-
<?php use Symfony\Component\HttpFoundation\JsonResponse; class ReaddToCartModuleFrontController extends ModuleFrontController { public $ajax = true; public function initContent() { parent::initContent(); $productId = Tools::getValue('id_product'); $quantity = Tools::getValue('qty', 1); // Debugging output error_log("Product ID: " . $productId); error_log("Quantity: " . $quantity); if (!$productId || !Validate::isUnsignedId($productId)) { error_log("Invalid product ID: " . $productId); $this->ajaxDie(json_encode(['success' => false, 'message' => 'Invalid product ID'])); } $cart = $this->context->cart; if (!$cart->id) { $cart->add(); $this->context->cookie->id_cart = $cart->id; } $updateQuantity = $cart->updateQty($quantity, $productId); if ($updateQuantity) { error_log("Product added to cart successfully"); $this->ajaxDie(json_encode(['success' => true, 'message' => 'Product added to cart'])); } else { error_log("Failed to add product to cart"); $this->ajaxDie(json_encode(['success' => false, 'message' => 'Failed to add product to cart'])); } } }
-
I'm trying to get the token used for the AJAX requests, but I can't I've tried to var tokenElement = document.querySelector('input[name="token"]'); return tokenElement ? tokenElement.value : ''; but this returns empty string My AJAX request is function updateCartQuantity(productId, newQuantity, direction) { var updateCartUrl = 'http://localhost:8080/carrito?update=1&id_product=' + productId + '&id_product_attribute=0&token='+ tokenElement +'&ajax=1&op='+direction ; $.ajax({ type: 'GET', url: updateCartUrl, success: function (response) refreshCart(); }, error: function (error) { console.error('Error updating:', error); } }); } But since the variable arrives empty, the request does not work for me, if I put a token written on the js, the request works correctly (I have copied and pasted the token that I use to check that the request works from another request that Prestashop has, but I can't access how this token is generated)
-
Hello, Is it possible to get the Ajaxcart working properly in Prestashop 1.7. Currently if set to YES the Ajaxcart works correctly, but if set to NO it doesn't work properly. I want it to be able to work correctly in both the YES and NO options. I have found the following workaround for making the cart work correctly when the switch is on NO, but it causes problems when in the switch is on YES. if (resp.modal) { showModal(resp.modal); } changed to if (resp.modal) { window.location.href=cart_url; } With this it does go to the Cart Summary page, but if you put the switch to YES it loads the Ajaxcart for a fraction of a second then goes to the Cart Summary page, which is not what I want. If anybody can help with this problem it would be appreciated. Thank you. Kathy
-
Hi guys and girls, Can you please help me with this issue. My add to cart suddently stopped working. When we press add to cart, there is no response. The cart remains empty. This happens from google chrome , Firefox , internet and also from any mobile . I did not have this issue before . I have not installed any new module. I have uninstalled and reinstalled the shopping cart module, and the problem still exists. The page gets updated, but nothing get added to the shopping cart, so the cart stays empty. Steps to reproduce the behavior: Go to https://benush.es/en/all_products/35-milk-chocolate-tablet-14 Click on Add to Cart See that Cart icon stays empty Additionnal information I use prestashop 1.7.6.2 PHP version: 7.2.34 Thanks in advanced
-
- shopping cart
- ajaxcart
-
(and 2 more)
Tagged with:
-
Hello everyone, I have trouble with my prestashop theme. When I press on login icon in the blockuserinfo the ajax cart is also opening! I tried to move the icon from the cart, but it is still opening. I think the problem is in blockuserinfo.tpl that they are both in the same <section> But I tried to seperate them and cart stopped to expand. The link to the site, that you could see the problem: http://vannalux.kz/ blockuserinfo.tpl <section id="header_user" class="blockuserinfo-cart header-box"> {if !$PS_CATALOG_MODE} <div id="shopping_cart"> <a href="{$link->getPageLink($order_process, true)}" title="{l s='View my shopping cart' mod='blockuserinfo'}" rel="nofollow"> <strong class="opancart"></strong> <span class="shopping_cart_title">{l s='Cart' mod='blockuserinfo'}</span> <span class="ajax_cart_quantity{if $cart_qties == 0} hidden{/if}">{$cart_qties}</span> <span class="ajax_cart_product_txt{if $cart_qties != 1} hidden{/if}">{l s='Product' mod='blockuserinfo'}</span> <span class="ajax_cart_product_txt_s{if $cart_qties < 2} hidden{/if}">{l s='Products' mod='blockuserinfo'}</span> {*<span class="price ajax_cart_total{if $cart_qties == 0} hidden{/if}"> {if $cart_qties > 0} {if $priceDisplay == 1} {assign var='blockuser_cart_flag' value='Cart::BOTH_WITHOUT_SHIPPING'|constant} {convertPrice price=$cart->getOrderTotal(false, $blockuser_cart_flag)} {else} {assign var='blockuser_cart_flag' value='Cart::BOTH_WITHOUT_SHIPPING'|constant} {convertPrice price=$cart->getOrderTotal(true, $blockuser_cart_flag)} {/if} {/if} </span>*} <span class="ajax_cart_no_product{if $cart_qties > 0} hidden{/if}">{l s='(empty)' mod='blockuserinfo'}</span> </a> </div> {/if} <div class="blockuserinfo header-box"> {if $logged} <a href="{$link->getPageLink('index', true, NULL, "mylogout")}" title="{l s='Log out' mod='blockuserinfo'}" class="logout" rel="tooltip" data-placement="bottom" data-original-title="first tooltip"><span><i class="icon-lock"></i></span></a> <a href="{$link->getPageLink('my-account', true)|escape:'html'}" title="{l s='View my customer account' mod='blockuserinfo'}" class="account" rel="nofollow"><span>{$cookie->customer_firstname} {$cookie->customer_lastname}</span></a> {else} <a href="{$link->getPageLink('my-account', true)}" title="{l s='Login' mod='blockuserinfo'}" class="login" rel="tooltip" data-placement="bottom" data-original-title="first tooltip" ><span><i class="icon-unlock"></i></span></a> {/if} </div> </section> Please help me to solve this problem, thanks!
-
Bonjour, Je rencontre actuellement un problème lors de l'ajout d'un produit au panier. Le problème est apparu du jour au lendemain sans qu'il n'y ai eu de changement sur le site. La version de prestashop est la 1.5.6.0 A l'origine le panier "Ajax" était activé, une alerte javascript retournait "ok." lors du click. Le json retourné par la requête est : {"hasError":true,"errors":["ok."]} Après désactivation du mode Ajax idem, sauf que le message d'erreur apparaît sur la page panier : J'ai tenté essayé de créer un nouveau produit, idem. Est-ce que quelqu'un aurait déjà rencontré ce problème ? Notre boutique est bloqué depuis ce matin nos clients ne peuvent plus rien commander.
-
Hello, Que signifie le paramètre callerElement dans la méthode : ajaxCart.add = function(idProduct, idCombination, addedFromProductPage, callerElement, quantity, whishlist) Je ne le trouve pas dans la doc prestashop. Merci.
-
- callerElement
- ajaxCart
-
(and 1 more)
Tagged with: