Solved

Reconstructing a Function from Static to Dynamic

Posted on 2007-11-26
2
237 Views
Last Modified: 2013-12-12
The following function is to be produced dynamically with the properties of various session variables assigned by a user's shopping cart. The shopping cart variables are looped like this:
<?php
//force cart to the beginning
$cartName->MoveFirst();
//start loop
while (!$cartName->EOF())      {
  <Code To set the variables>
  //Move to the next item
  $cartName->MoveNext();
}
//force cart to the beginning
$cartName->MoveFirst();
?>

Below is the code that needs to become dynamic. How can I do this?
$item_1 = new GoogleItem("item name",      // Item name

                               "item desc", // Item      description

                               $total_count, // Quantity

                               10); // Unit price

      $cart->AddItem($item_1);

Open in new window

0
Comment
Question by:EMB01
2 Comments
 
LVL 6

Accepted Solution

by:
baev earned 500 total points
ID: 20352259

$i=0; //I don't know whether your cart needs this counter

$items = array();

while (!$cartName->EOF()){

  $items[$i] = new GoogleItem($item_name_from_session, //I don't know the real name of your variable

                               $item_desc_from_session, //I don't know the real name of your variable

                               $total_count_from_session, //I don't know the real name of your variable

                               $unit_price_from_session); //I don't know the real name of your variable

  $cart->AddItem($items[$i]);

  $i++;

  $cartName->MoveNext();

} 

Open in new window

0
 
LVL 14

Author Closing Comment

by:EMB01
ID: 31411032
I have an issue with the Google Checkout (http://www.experts-exchange.com/Web_Development/Internet_Marketing/E-Commerce/Stores_and_Carts/Q_22976762.html), so I don't quite know that this worked - but I will accept it as a solution for now. Thank you.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
uploading image to a profile page 7 33
Apache/PHP: Cannot make phpinfo() and phpmyadmin work 4 33
simplest php form 3 57
Hacked File Timestamps 4 47
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to count occurrences of each item in an array.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now