Solved

Reconstructing a Function from Static to Dynamic

Posted on 2007-11-26
2
242 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 7

Accepted Solution

by:
Dmitrii 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

Webinar: MongoDB® Index Types

Join Percona’s Senior Technical Services Engineer, Adamo Tonete as he presents “MongoDB Index Types, How, When and Where Should They be Used?” on Wednesday, July 12, 2017 at 11:00 am PDT / 2:00 pm EDT (UTC-7).

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

628 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