Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Add quantity input box within product list grid for Crisp White Skin

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 11-24-2016, 03:46 AM
 
eclecticsolutions eclecticsolutions is offline
    
Join Date: Nov 2016
Posts: 1
 

Default Add quantity input box within product list grid for Crisp White Skin

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.
Attached Thumbnails
Click image for larger version

Name:	caramarine.PNG
Views:	267
Size:	133.8 KB
ID:	4755  
__________________
X Cart -> 5.3.1.3
Reply With Quote
  #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
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 08:34 PM.

   

 
X-Cart forums © 2001-2020