Jump to content
greasemonkey

Quantity box in product listing 1.2 for 2.3

Recommended Posts

Here is a simple (2 file changes) mod to add a quantity box to your Buy Now button on product_listing for 2.3.x.

 

Located HERE

 

Works with attributes by directing customer to product_info.

 

If anyone wishes to contribute further I would love to figure out how to have the qty added to the box, when you are using buy now with a product with attributes, carried forward to the product_info qty box (a separate addon).

Share this post


Link to post
Share on other sites

Hi Scott,

 

I am currently trying to get this set up for my site however as my product_info file has already been modified I am unsure how to do step 2:

 

change from;
 $prod_list_contents .= '	    <td align="center">' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing[$x]['products_id'])) . '</td>';

to ----->

  $prod_list_contents .= '	    <td align="center">' . tep_draw_form('buy_now', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id='. $listing[$x]['products_id']), 'POST') . '<table cellSpacing="0" cellPadding="0" width="100%"><tr><td align="right" width="25%">' . tep_draw_input_field('buyqty', '1', 'size=3 maxlength=3') . '</td><td align="center" width="75%" valign="absmiddle">' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart') . '<td align="absmiddle">' . '</td></tr></table></form>';

 

 

 

 

The code I have is as follows:

 

 

 

case 'PRODUCT_LIST_BUY_NOW':
	 $prod_list_contents .= '	    <td align="center">' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'products_id')) . 'action=buy_now&products_id=' . $listing['products_id'])) . '</td>';

	    $prod_list_grid .= '<br>' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']));
	    break;
    }

 

I am using a Grid product layout for some pages.

 

Any help with figuring out what I need to do to correctly add in the quantity boxes would be great. I am able to get the quantity box to appear alongside the buy now button however the functionality of the produced actually being added to the shopping cart is not working.

 

Thanks,

David

Share this post


Link to post
Share on other sites

@@The Lego Man, so I understand correct... you can get the box to show, it just doesn't work (add to cart)?

 

Have you made the changes to application_top?

 

Also, It may help to show what you changed your code "to" to get it box showing in product_listing...

Share this post


Link to post
Share on other sites

@@greasemonkey

 

Thank you for the reply!

 

Yes, I have made the changes to application_top

 

To get the box to appear where I want it, I simply placed your suggested code in the the prod_list_grid line (please see below)

 

Note - changing the $prod_list_contents had no effect, probably as I am using a grid layout for my products - so this line (second line) is unchanged in both code snippets below.

 

 

My previous code was as follows:

 

case 'PRODUCT_LIST_BUY_NOW':

	 $prod_list_contents .= '	 <td align="center">' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'products_id')) . 'action=buy_now&products_id=' . $listing['products_id'])) . '</td>';

	 $prod_list_grid .= '<br>' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']));

	 break;

 

 

Replaced with:

 

case 'PRODUCT_LIST_BUY_NOW':

$prod_list_contents .= '	 <td align="center">' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'products_id')) . 'action=buy_now&products_id=' . $listing['products_id'])) . '</td>';

	 $prod_list_grid .= '<br>' . tep_draw_form('buy_now', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id='. $listing[$x]['products_id']), 'POST') . '<table cellSpacing="0" cellPadding="0" width="100%"><tr><td align="right" width="25%">' . tep_draw_input_field('buyqty', '1', 'size=3 maxlength=3') . '</td><td align="center" width="75%" valign="absmiddle">' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart') . '<td align="absmiddle">' . '</td></tr></table></form>';

 break;	

 

See screenshot of before (L) and after (R ) below is shown here http://minifigbay.com/after.png

Edited by The Lego Man

Share this post


Link to post
Share on other sites

Try changing this;

 

$prod_list_grid .= '<br>' . tep_draw_form('buy_now', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id='. $listing[$x]['products_id']), 'POST') . '<table cellSpacing="0" cellPadding="0" width="100%"><tr><td align="right" width="25%">' . tep_draw_input_field('buyqty', '1', 'size=3 maxlength=3') . '</td><td align="center" width="75%" valign="absmiddle">' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart') . '<td align="absmiddle">' . '</td></tr></table></form>';

 

to

 


$prod_list_grid .= '<br>' . tep_draw_form('buy_now', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id='. $listing['products_id']), 'POST') . '<table cellSpacing="0" cellPadding="0" width="100%"><tr><td align="right" width="25%">' . tep_draw_input_field('buyqty', '1', 'size=3 maxlength=3') . '</td><td align="center" width="75%" valign="absmiddle">' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart') . '<td align="absmiddle">' . '</td></tr></table></form>';

Share this post


Link to post
Share on other sites

@@greasemonkey

 

Hi again,

 

Just curious as to whether it is possible to have the quantity box display on the product's individual page as well as the on the category page. Currently I have it working on the category page but if you click on a product it doesn't show.

Share this post


Link to post
Share on other sites

@@greasemonkey

 

I downloaded qbox and uploaded the files from the aas_v0.2_bugfixes folder. No files were overwritten so I'm taking it that all files were new.

 

I don't see any difference to the product page. No qty box visible. Did I only upload files to fix a bug ?

 

Any ideas?

Share this post


Link to post
Share on other sites

I'm not sure what you installed... I would un do it. There should be no new files... Only a couple quick edits to product_info (and product info language file) and application_top.

 

Don't forget to back up first!!!!!

 

This is the one I use; http://addons.oscommerce.com/info/7914 @@The Lego Man

Share this post


Link to post
Share on other sites

@@greasemonkey

 

I have added the code as you have specified in the post #5. I can see the quantity box and can add items to the card, however no matter whether I use the line or grid layout the quantity box display is very long (it should only have size=3) and therefore the whole layout looks messed up. I am using oscommerce 2.3.3.4 with MTS if this is of any help.

 

Please advice what should be done to have a nice neat box displayed.

Share this post


Link to post
Share on other sites

Hi,

 

I was pointed to this add-on by another forum member, and I applied it to a one-click-install of osC2.3.4 and it worked fine for me.

I have now installed 2.3.4BSGOLD, and The second file that needs to be modified does not have the correct original line in it, well it does, but it is very different. The forum member who pointed me in the direction of this add-on also said that it is easy to change it for BS2.3.4. Has anyone here done so? if so would you be willing to share?

 

regards,

dave.

Share this post


Link to post
Share on other sites

Hi @@greasemonkey,

 

According to the install.txt  there are two parts to the install, the first was to modify /includes/application_top.php . That was a simple copy and paste job.

 

 

The second part requires you to replace the following in /includes/modules/product_listing.php

 

change from;
  $prod_list_contents .= '        <td align="center">' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id'])) . '</td>';
          
 
to ----->
   $prod_list_contents .= '        <td align="center">' . tep_draw_form('buy_now', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id='. $listing['products_id']), 'POST') . '<table cellSpacing="0" cellPadding="0" width="100%"><tr><td align="right" width="25%">' . tep_draw_input_field('buyqty', '1', 'size=3 maxlength=3') . '</td><td align="center" width="75%" valign="absmiddle">' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart') . '<td align="absmiddle">' . '</td></tr></table></form>';
 
 
I cannot find the exact line to change, the closest I can find is (line 221 in my case) :
 
$prod_list_contents .= '       <div class="col-xs-6 text-right">' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing[$x]['products_id']), NULL, NULL, 'btn-success btn-sm') . '</div>';
 
 
regards,
dave.
Edited by DavidSJohnston

Share this post


Link to post
Share on other sites

@@DavidSJohnston..... Look here

     $prod_list_contents .= '        <div class="col-xs-6 text-right">' . tep_draw_form('buy_now', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id='. $listing['products_id'], $request_type), 'POST') . tep_draw_input_field('buyqty', '1', 'style="width:44px;text-align:center;"', 'tel') . ' ' . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', NULL, NULL, NULL, 'btn-success btn-sm') . '</form></div>';
Edited by greasemonkey

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×