X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   Add quantity input box within product list grid for Crisp White Skin (https://forum.x-cart.com/showthread.php?t=74714)

eclecticsolutions 11-24-2016 03:46 AM

Add quantity input box within product list grid for Crisp White Skin
 
1 Attachment(s)
http://caramarine.com/new-arrivals -> On the product list page for any category, I have hidden Add to Cart button and it shows up only if user is logged in.
Page Link

How can I add a quantity box within the product grid so that when a logged in user clicks on "Add to Cart", the specified quantity of the product gets added to cart ? See attached screenshot.

Currently, quantity gets added as 1 in cart and there I need option to specify quantity directly on product list page before adding to cart.

qualiteam 01-24-2017 03:19 AM

Re: Add quantity input box within product list grid for Crisp White Skin
 
This action is performed in background via an AJAX call from this JavaScript file:
skins/customer/items_list/product/products_list.js

The function that performs the call is this one:
ProductsListView.prototype.addToCart = function (elem) {}

The template file that renders the button in product grids is this one:
skins/customer/items_list/product/parts/grid.button-add2cart-wrapper.twig

If you check the file, you will see that the button is injected into "itemsList.product.grid.customer.tail" list.

So, to add the quantity selector you should:
1. Create a custom module
2. In the module create a new template file that will inject the input box into the same "itemsList.product.grid.customer.tail" list (use the "weight" attribute to control a position of the widget among others in this list).
3. In the module create a new JS file that will replace ProductsListView.prototype.addToCart with your custom function that will pass the specified quantity in the "add-to-cart" request to the server.
4. In the module "decorate" \XLite\View\ItemsList\Product\AProduct class and make the getJSFiles() method load your JS file.


All times are GMT -8. The time now is 02:59 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.