Input Cart 'QTY' within Products page

titch2k6

Avatar: titch2k6

2014-01-03 13:21

Hi guys and gals.

Using v6.3 and modified most of the script to turn the Shopping Cart into a basic Materials Picker.

I have basic pHp knowledge, so please be gentle, and trawled through what was required (learning quite a bit on the way!!), but now need something that is just outside my capability and looking for help/pointers......

I need a way to input QUANTITY at the products page BEFORE adding to cart. Although QUANTITY and SAVE operate within the basket fine, I require it done this way due to how the site is going to be used out in the field.

I have tried looking through forum, but can only find snippets of info, and all relating to older versions, of what I actually need.

Any help, input or advice appreciated.

» Quick.Cart v6.x

Learning pHp the hard way!!

boboo

Avatar: boboo

2014-01-03 20:29

In the main product view, it is easy. Just change the type of input (iQuantity) from "hidden" to "text" in templates/default/product.php
Then give it an ID or class and format it the css.

In the products list view, it is a bit more difficult, because there is no form to send the data through POST, the variables iProduct and iQuantity ("hard wired" to 1) are given through GET in the address link.
(just move with the mouse over the link and observe the status bar in the browser - you will see the address and ID of iProduct and the iQuantity set to 1).

The easiest but dirty ;-) solution is to use a line of js code in the tag <a> which gives the above mentioned link.
We change with onclick event the value of iQuantity.

In the core/products.php in the function listProducts find:

<div class="basket">


and add direcly behind it:

<input type="text" id="iQuantity'.$aData['iProduct'].'" value=""/>


then change this:

<a href="'.$sBasketPage.'&amp;iProductAdd='.$aData['iProduct'].'&amp;iQuantity=1" rel="nofollow" title="'.$lang['Basket_add'].': '.$aData['sName'].'">


to:

<a href="'.$sBasketPage.'&amp;iProductAdd='.$aData['iProduct'].'&amp;iQuantity=1" rel="nofollow" title="'.$lang['Basket_add'].': '.$aData['sName'].'" onclick="var iQ=this.getAttribute(\'href\').replace(\'iQuantity=1\',\'iQuantity=\'+gEBI(\'iQuantity'.$aData['iProduct'].'\').value);this.setAttribute(\'href\',iQ);">



Give the added input a class or ID and format it in css

That's all. Just checked with QC6.3Add. Works.

boboo :-)

titch2k6

Avatar: titch2k6

2014-01-04 14:19

Many thanks for that boboo, but did not work right for me - think it is because I had extra field on products page and everything go messed up......

I have done a work around by removing the "Add To Basket" from the products list page. Now, the user clicks on the product in the list (via the image link), where they are taken to the product information page, and using the information you gave in the first part of your post, the quantity is adjusted before being added to basket.

Thanks boboo for a kick in the right direction!!

Learning pHp the hard way!!

Back to top
about us | contact