View Single Post
  #2  
Old 01-24-2017, 03:19 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default 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.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote