Jump to content

maria

Member
  • Posts

    5
  • Joined

  • Last visited

maria's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Hi Benjamin, When you said: Wouldn't you want to redirect them after they click the "checkout" button? Yes, that's what I really wanted to do, I just could not figure out how to say it right. I always want the visitor to see the cart page all the time. Would you suggest that I should create another checkout page with all same info where all these things happen? Then I'll try the ">=". and see what happens. Many thanks, Maria
  2. Thanks for looking up quickly. Here's the error: Parse error: syntax error, unexpected T_DOUBLE_ARROW in /Applications/xampp/xamppfiles/htdocs/XML/p7c/cart2.php on line 89 Also, I just copied that statement "if($cart) {...} else {print "Your Cart is empty!}" somewhere that I don't remember now. Is that where the problem could be? I am repasting the code where I added the if and else statement that didn't work. If the total is equal to or more than $100, it should take them to the delivery page, but if not, then to pick-up page. Or is there any better alternative? I really appreciate your help. Maria ----- <? $xml = new SimpleXMLElement(file_get_contents("store.xml")); session_start(); $cart = $_SESSION["cart"]; ?> <? require_once("head.php"); ?> <? if($cart) { ?> (X)ItemSizeQuantityUnit PriceItem Subtotal <? $keys = array_keys($cart); foreach($keys as $key) { $array = explode(".", $key); $name = $array[0]; $size = $array[1]; $quantity = $cart["$key"]; $price = $xml->xpath("//item[@name=$name]/price[@size=$size]"); $unitPrice = (float) $price[0]; $itemSubtotal = $unitPrice * $quantity; $total = $total + $itemSubtotal; ?> remove <? print($name); ?> <? print($size); ?> <? print($quantity); ?> $<? printf("%0.2f", $unitPrice); ?> $<? printf("%0.2f", $itemSubtotal); ?> <? } ?> Total: $<? printf("%0.2f", $total); ?> <? ?> <? } else { ?> Your cart is empty! <? } ?> <? if ($total=>100) { header ('Location: Delivery.php'); } else { header ('Location: pickUp.php'); } ?> Go Back to Shopping <? require_once("end.php"); ?>
  3. Hi There, Following Jon's video tutorial I am trying to add shipping method to my cart(instead of using paypal I would rather have the order emailed to myself and the visitor). If the total is $100 + they get free delivery, however, if it is less, they get a different option. I used if - else statement but it threw me an error. Can anyone take a look at my code and see where I messed up? Thanks, Maria <? if($cart) { ?> (X)ItemSizeQuantityUnit PriceItem Subtotal <? $keys = array_keys($cart); foreach($keys as $key) { $array = explode(".", $key); $name = $array[0]; $size = $array[1]; $quantity = $cart["$key"]; $price = $xml->xpath("//item[@name=$name]/price[@size=$size]"); $unitPrice = (float) $price[0]; $itemSubtotal = $unitPrice * $quantity; $total = $total + $itemSubtotal; ?> remove <? print($name); ?> <? print($size); ?> <? print($quantity); ?> $<? printf("%0.2f", $unitPrice); ?> $<? printf("%0.2f", $itemSubtotal); ?> <? } ?> Total: $<? printf("%0.2f", $total); ?> <? ?> <? } else { ?> Your cart is empty! <? } ?>
  4. Thanks Rob, I'll try that, my problem is how to slap it in to my index.php file. I am confused where to do it, and how to affect the correct price that will go to my shopping cart. foreach($results as $item) { print(" {$item->name}{$item->price[0]}add to cart{$item->price[1]}add to cart"); } :/Maria
  5. Hi, I watched your tutorial last night and purchased the CD right away. I thought your solution will help my work, except that my problem is, there are 2 different prices inside my xml file: Here is a snippet: Action Learning 3 4.50 I used the foreach loop as you demoed in my php index file. But how can I include 2 different prices, so the calculaiton in my shopping cart is correct? Thank you for your help. Maria
×
×
  • Create New...