Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Quantity box in product_listing 1.2 for 2.3


freakystreak

Recommended Posts

Has anyone managed to get this contribution to work? I've installed it but it will not add the quantity to the product_info.php page. Been working on this for about 6 hours now and I can't get it to work. Doesn't seem to be any support for it on here.

 

My code:

 

application_top.php

 

<?php
if (isset($HTTP_GET_VARS['products_id'])) {
if (tep_has_product_attributes($HTTP_GET_VARS['products_id'])) {
tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id']));
} else {
  if($HTTP_POST_VARS['buyqty']=="") {
$quantity = 1;
  }else{
$quantity = $HTTP_POST_VARS['buyqty'];
  }
$cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id'])+$quantity);
}
}
tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
break;?>
 

Here's my product_listing.php

<?php$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>';
break;?>

Anyone got it to work?

Edited by freakystreak

Ah, the world wide web. What a wonderful place.

Link to comment
Share on other sites

Hi,
 
What is not clear with the installation instructions?
In product_listing.php find:

$prod_list_contents .= '        <tr><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>';

replace it with: 

 $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>';

No idea why you added an opening <?php and a closing ?> to that passage!? :wacko:

And the same procedure in application_top.php: Find the code snippet mentioned in the install.txt and replace it by the other snippet. It's simple "copy and paste".

 

J.J.

Edited by De Dokta
Link to comment
Share on other sites

@@freakystreak It looks like you've made a couple errors... Its a very simple install may just start again from scratch (sometimes we chase our tails... been there done that)?

 

Here is the support thread btw... http://www.oscommerce.com/forums/topic/392636-quantity-box-in-product-listing-12-for-23/

 

On top of what J.J. mentioned it looks like you've added  php tags to the application_top and also missed some of the code.

Link to comment
Share on other sites

Thanks for the responses.

Ignoring the php quotes, which were included because I was under the impression that when adding code snippets you should include opening and closing php tags, my code is exactly what the install says. I've even used a default, fresh oscommerce installation to test and it does not pass the quantity from product listing to product info.

 

application top

case 'buy_now' :        if (isset($HTTP_GET_VARS['products_id'])) {
  if (tep_has_product_attributes($HTTP_GET_VARS['products_id'])) {
    tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id']));
  } else {
    //modification by Alexander Dimelow (www.web-project.co.uk)
    if($HTTP_POST_VARS['buyqty']=="") {
      $quantity = 1;
    }else{
      $quantity = $HTTP_POST_VARS['buyqty']; 
    }
    //end of modification by Alexander Dimelow (www.web-project.co.uk)
    $cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id'])+$quantity);
  }
}
tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
break;

product listing

case 'PRODUCT_LIST_BUY_NOW':
  $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>';
break;

and even my product info

<span class="buttonAction"><?php echo '<span class="text">' . TEXT_ENTER_QUANTITY . ' ' . tep_draw_input_field('cart_quantity', '1', 'size="5" style="vertical-align:middle;"') . '</span> ' . tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_draw_button(IMAGE_BUTTON_IN_CART, 'cart', null, 'primary'); ?></span>

only thing added in the quantity box on the product_info.php because by default OSCommerce doesn't have one of that page.

Ah, the world wide web. What a wonderful place.

Link to comment
Share on other sites

Apologises, I think I may found the problem. I've taken out the code that show the quantity box on the product info page and now the code works. Only, I need to show the quantity box on the product info page as well. The problem is passing the post value of 'buyqty' into the input field for the quantity box. I'm guessing it should be something like this:

<span class="buttonAction"><?php echo '<span class="text">' . TEXT_ENTER_QUANTITY . ' ' . tep_draw_input_field('cart_quantity', $HTTP_POST_VARS['buyqty'], 'size="5" style="vertical-align:middle;"') . '</span> ' . tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_draw_button(IMAGE_BUTTON_IN_CART, 'cart', null, 'primary'); ?>

although that doesn't work but something similar. Any ideas?

Ah, the world wide web. What a wonderful place.

Link to comment
Share on other sites

Hi,

 

it does not work because in product_info.php the action normally is not 'buy_now', but 'add_product':

<?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product'));

Either you try to change the case 'add_product' in application_top.php similar to the case 'buy_now', or you try to replace 'action=add_product' with 'action=buy_now' in the above mentioned passage.

 

J.J.

Edited by De Dokta
Link to comment
Share on other sites

  • 3 years later...

 $sel ="<select  size=\"1\"   name=\"buyqty\">";
                       for ($i=1; $i <= $st; $i++) {
                    $sel.= "<option>".$i."</option>";
                       }
                    $sel.= "</select> ";
    
                                        
                                        
     $prod_list_contents .= '<div class="col-xs-7"  >' . 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'], $request_type), 'POST') .  $sel  . tep_draw_button(IMAGE_BUTTON_BUY_NOW, 'cart', NULL, NULL, NULL, 'btn-success')  .'</form></div>'; 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...