Many thanks, Chris.

I have one additional question about this shopping cart project.  I need
to make a submit button for the purpose of removing an item from the
shopping cart.

<input type="submit" name="submit" value="Remove" class="place_order"/>

What I am struggling with is to find an effective method for passing the
product serial number (auto_increment in the table it is stored in) so I
know which product the user is removing from their purchase.  Then I will
just unset the session variable that matches.

What are your suggestion(s)?

Thank you your help with my original question Chris.

Ron

> $_SESSION['life_coaching_order'][$product][$gift]['quantity'] =
> $_SESSION['life_coaching_order'][$product][$gift]['quantity'] + 1;
> ===
>
> ...
>
> ===
> foreach ($_SESSION['life_coaching_order'] AS $coaching_fee_theme_reference
> => $value ) {
> ===
>
>
> In this example $value would be an array. To test if it is a gift or not
> you
> would do this from within the foreach loop:
>
> //gift
> if ( isset($value[1]) && isset($value[1]['quantity']) )
> {
>   $gift_quantity = $value[1]['quantity'];
> }
>
> //personal use
> if ( isset($value[2]) && isset($value[2]['quantity']) )
> {
>   $personal_quantity = $value[2]['quantity'];
> }
>
>
> Technically the above IF's are optional, but they are proper syntax.
>
> I don't know how you are with OOP, but you may have more luck using
> objects
> instead of a complex array.
>
> Chris H.
>
>
> On Thu, Oct 7, 2010 at 3:35 PM, Ron Piggott
> <ron.pigg...@actsministries.org>wrote:
>
>>
>> I am writing a custom shopping cart that eventually the "cart" will be
>> uploaded to PayPal for payment.  I need to be able to include the option
>> that the purchase is a gift certificate.
>>
>>
>>
>> At present my "add to cart" function goes like this:
>>
>> ===
>> # Gift Certificate: 1 is a gift; 2 is personal use
>>
>> if ( $gift_certificate == "yes" ) {
>>        $gift = 1;
>> } else {
>>        $gift = 2;
>> }
>>
>> $_SESSION['life_coaching_order'][$product][$gift]['quantity'] =
>> $_SESSION['life_coaching_order'][$product][$gift]['quantity'] + 1;
>> ===
>>
>> Now I need to display the shopping cart contents.  I want to do this
>> through an array as the contents of the shopping cart are in a session
>> variable.  I start displaying the shopping cart contents by a "FOREACH"
>> loop:
>>
>> ===
>> foreach ($_SESSION['life_coaching_order'] AS
>> $coaching_fee_theme_reference
>> => $value ) {
>> ===
>>
>> What I need help with is that I don't know how to test the value of
>> $gift
>> in the above array if it is a 1 or 2 (which symbolizes this is a gift
>> certificate).
>>
>> I have something like this in mind:
>> if ( $_SESSION['life_coaching_order'] == 2 ) {
>>
>> But I don't know how to access all the components of the array while I
>> am
>> going through the FOREACH loop.
>>
>> By using a "1" or "2" I have made gift certificates their own product.
>> If
>> you a better method I could use please provide me with this feedback.
>>
>> Ron
>>
>> The Verse of the Day
>> Encouragement from God's Word
>> www.TheVerseOfTheDay.info
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>



The Verse of the Day
Encouragement from God's Word
www.TheVerseOfTheDay.info


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to