Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Quantity Box in Product Info


zohab

Recommended Posts

Hi Everybody

 

I have one problem ,i need help .

 

I need product quantity box in product_info.php page in my project.

I had searched all contributions

I find two contributions related to it.

 

1)Quantity Box in Product Listing

2)Quantity Box in New Products v1.0

 

 

But i need Quantity Box in Product Info

 

I am not getting how to implement this?

 

Please help me .

I need help.

 

 

Best regards

zohab

Link to comment
Share on other sites

***Editing Histoty****

 

10/24/2006 - by Jack_mcs

- Fixed bugs so it now works correctly

 

7/19/2005

-CHANGED APPLICATION TOP CODE/WAS NOT ADDING PRODUCTS W/OUT ATTRIBUTES.

 

***END EDITING HISTORY***

 

 

My first contrubution. Have not seen one like it, and my store needed it greatly.

Many products with many attributes and did not want the customer to have to keep

going back to add more of a different attribute from the product info page.

 

You can email me [email protected] with subject OSCommerce (otherwise I will delete it :) ).

 

This contrubution allows you to:

 

1. List the product attrubutes on the product_info.php page in a table instead of the pull-down menu.

2. Adds a quantity input box for each attribute.

3. Shows the actual price with the attribute instead of the '+/- XXX'

(easily edited if you do not like it, search for all instances of $price_with_attribute and change as necessary).

4. Lists the model number

(currently commented out, just search for 'uncomment if you want to show the model number' and uncomment.

I run a hack that each attribute has a different model #)

5. I have this running with Seperate Pricing and it runs fine.

6. Currently working with just one attribute option type (ex. size or color; not both). Had no need to edit

it but if you want just make:

tep_draw_hidden_field('b[]',$products_options_name['products_options_id']) in the product_info.php an array ;

then add another while or for loop in the application_top.php and it should work.

 

Example 1 :

 

Option Price Quantity

8 mb $349.99 |_|

 

16 mb $369.99 |_|

 

 

Example 2 :(with model uncommented):

 

Option Model Price Quantity

8 mb 123456 $349.99 |_|

 

16 mb 123457 $369.99 |_|

 

If you have a fresh install of OScommerce you may just copy the files over.

 

If you have other contributions installed, it is HIGHLY suggested that you follow the install

instructions below for each file.

 

FIRST BACKUP! BACKUP! BACKUP! BACKUP! BACKUP! BACKUP! BACKUP! BACKUP!

 

This contrub changes the following files:

catalog/product_info.php

catalog/includes/application_top.php

catalog/includes/languages/english/product_info.php

 

***************************BEGIN INSTALL*************************************************************************

*******

 

**********************************

product_info.php

**********************************

 

Around line 47 (changing action of form to use new action / case='add_mult'):

 

Find:

 

<td width="100%" valign="top"><?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product')); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">

 

REPLACE with:

 

<td width="100%" valign="top"><?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_mult')); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">

 

-----------------------------------------------------------------------------

Around line 48 (creating the layout of the table for attributes to go into):

 

Find:

<tr>

<td class="main" colspan="2"><?php echo TEXT_PRODUCT_OPTIONS; ?></td>

</tr>

<?php

 

REPLACE with:

<tr>

<td class="main" align="center"><?php echo TEXT_PRODUCT_OPTION; ?></td>

<td class="main" align="center"><?php /* uncomment if you want to show the model number echo TEXT_PRODUCT_MODEL; */ ?></td>

<td class="main" align="center"><?php echo TEXT_PRODUCT_PRICE; ?></td>

<td class="main" align="center"><?php echo TEXT_PRODUCT_QUANTITY; ?></td>

</tr>

<?php

$X=0;

 

-----------------------------------------------------------------------------

Around Line 138 (listing the attributes in table form):

 

Find:

$products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']);

if ($products_options['options_values_price'] != '0') {

$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';

 

Under this ADD ( before the } ):

 

if ($products_options['price_prefix'] == '+') {

$price_with_attribute = ($product_info['products_price'] + $products_options['options_values_price']);

} else {

$price_with_attribute = ($product_info['products_price'] - $products_options['options_values_price']);

}

?>

<tr>

<td class="main" align="center">

<?php echo $products_options['products_options_values_name'];

echo tep_draw_hidden_field('a[]', $products_options['products_options_values_id']);

echo tep_draw_hidden_field('b[]',$products_options_name['products_options_id']); ?> </td>

<td class="main" align="center">

<?php /* uncomment if you want to show the model number

echo $product_info['products_model']; */

?>

</td>

<td class="main" align="center"><?php echo $currencies->display_price($price_with_attribute, tep_get_tax_rate($product_info['products_tax_class_id'])); ?></td>

<td class="main" align="center"><?php echo tep_draw_input_field('quantity[]',$value = '0',"size=2");?></td>

</tr>

<?php

$x++;

 

-----------------------------------------------------------------------------

Around Line 152 (removing the pull-down menu):

 

FIND & DELETE or COMMENT OUT:

 

?>

<tr>

<td class="main"><?php echo $products_options_name['products_options_name'] . ':'; ?></td>

<td class="main"><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?></td>

</tr>

<?php

 

**********************************

includes/application_top.php

**********************************

Around Line 330 (adding the new case of action='add_mult'):

 

Find:

 

// customer adds a product from the products page

case 'add_product' : if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {

 

Above this ADD:

// customer adds multiple products from the product_info page

case 'add_mult' : if (is_array($HTTP_POST_VARS['a'])){

reset($HTTP_POST_VARS['quantity']);

reset($HTTP_POST_VARS['a']);

$x=0;

 

if (is_array($HTTP_POST_VARS['a'])){

foreach(($HTTP_POST_VARS['a']) as $key => $value){

$c = array((int)$HTTP_POST_VARS['b'][$x] => (int)$value);

 

if (is_array($HTTP_POST_VARS['quantity'])){

$qty = (int)$HTTP_POST_VARS['quantity'][$x];

$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], ($c)))+($qty),($c));

$x++;

}

}

}

} else {

if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {

$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']);

}

}

tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));

break;

 

***************************

catalog/includes/languages/english/product_info.php

***************************

 

at the end of the file before last ?>

 

ADD:

define('TEXT_PRODUCT_OPTION', 'Option');

define('TEXT_PRODUCT_MODEL', 'Model');

define('TEXT_PRODUCT_QUANTITY', 'Quantity');

define('TEXT_PRODUCT_PRICE', 'Price');

 

Thats it!

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...