Not for official support
We do not provide technical support in this forum.
If you want to contact our customer support, please use our support form.
You are not logged in.
Hello everybody!
I need your help for this one. I tried to add a field called SIZE to the shopping cart, since I sell apparel. Have you tried to modify the shopping_cart.php file? I've already added the field in the database and in the shopping cart template. Now I need the php code which will send the new information to the database and also to the Orders section in the admin back-end panel. How to do that? I appreciate your help, since I like the shop-script free and I want to continue using it.
Last edited by Amynka (2010-01-10 10:32)
Offline
I found this in the PHP Shopping cart tutorial:
Shopping cart:
Here we use two array to store products in the shopping cart:
$_SESSION["gids"] contains productID values of the products which are currently in the customer's shopping cart.
$_SESSION["counts"] contains item quantities information - how many items of a certain product are there in customer's cart.
I guessed I had to add the new field first in the SS_products structure. I did it. There I chose the SET type and insert the VALUES 'M','L','XL' and saved it. Now I have 17 rows in the SS_products table.
After that I opened the shopping_cart.tpl.html file and found the table structure that appears on the front end. I added the new field in the menu so it looks like:
<form action="index.php" method=post>
<table width=75% border=0 cellspacing=0 cellpadding=5>
<tr align="center" bgcolor="#{$smarty.const.CONF_MIDDLE_COLOR}">
<td class="menu">{$smarty.const.TABLE_PRODUCT_NAME}</td>
<td class="menu">{$smarty.const.TABLE_PRODUCT_QUANTITY}</td>
<td class="menu">{$smarty.const.TABLE_PRODUCT_SIZE}</td>
<td class="menu">{$smarty.const.TABLE_PRODUCT_COST}</td>
<td width=20></td>
</tr>Here, in the second row of the table appear the values shown to the customer:
{section loop=$cart_content name=i}
<tr bgcolor=white>
<td><a href="index.php?productID={$cart_content[i].id}">{if $cart_content[i].product_code ne ""}[{$cart_content[i].product_code}] {/if}{$cart_content[i].name}</a></td>
<td align=center><input type="text" name="count_{$cart_content[i].id}" size=5 value="{$cart_content[i].quantity}"></td>
<td align=center><input type="set" name="count_{$cart_content[i].id}" size=5 value="{$cart_content[i].Size}"></td>
<td align=center>{$cart_content[i].cost}</td>
<td align=center><a href="index.php?shopping_cart=yes&remove={$cart_content[i].id}"><img src="images/button_delete.gif" border=0 alt="{$smarty.const.DELETE_BUTTON}"></a></td>
</tr>
{/section}And finally the total cost:
{section loop=$cart_content name=i}
<tr bgcolor=white>
<td><a href="index.php?productID={$cart_content[i].id}">{if $cart_content[i].product_code ne ""}[{$cart_content[i].product_code}] {/if}{$cart_content[i].name}</a></td>
<td align=center><input type="text" name="count_{$cart_content[i].id}" size=5 value="{$cart_content[i].quantity}"></td>
<td align=center><input type="set" name="count_{$cart_content[i].id}" size=5 value="{$cart_content[i].Size}"></td>
<td align=center>{$cart_content[i].cost}</td>
<td align=center><a href="index.php?shopping_cart=yes&remove={$cart_content[i].id}"><img src="images/button_delete.gif" border=0 alt="{$smarty.const.DELETE_BUTTON}"></a></td>
</tr>
{/section}Then the form is closed:
<input type=hidden name=update value=1>
<input type=hidden name=shopping_cart value=1>
<p>
<table width=75% border=0>
<tr><td align=right><input type="submit" value="{$smarty.const.UPDATE_BUTTON}"></td></tr>
</table>
</form>Of course I also defined the table title in the language.php file.
What is wrong or missing? It seems all right in the database, since I can set the SIZE there. I would try to add some kind of "SELECT SIZE" option in the product_detailed template, but I don't understant what does the $product_info[number] mean.
So, please, help! I really try to learn how to edit it. Thanks in advance.
Offline
If there's multiple sizes how do you track the quantity of them? I sell boots. One boot can have several sizes, and I can't simply have people buy 12 of a boot I only have 2 of because there is only one available quantity field.
Offline
Here we use two array to store products in the shopping cart:
$_SESSION["gids"] contains productID values of the products which are currently in the customer's shopping cart.
$_SESSION["counts"] contains item quantities information - how many items of a certain product are there in customer's cart.
Offline
which size add for the shopping cart?
Offline