0

So we have an issue with using a silly item/product based shipping, aka the user adds a product to the cart (FedEx/USPS) and the cost is added to shipping. If X amount of items are in teh cart, the rate increases due to products being shipped via envelope to being shipped via box. This incurs an additional 20$ service charge. I would like to append an additional 20$ to cart costs if X items are met, but am having an issue with adding this to the session information (and having it stick). Using this code, I can add an additional cost to shipping:

    # %install_dir%/catalog/checkout_shipping.php
    $_SESSION['cart']->total = $_SESSION['cart']->total + 20;
    var_export($cart);

This does not reflect in my shopping cart module/sidebar with he current price though. Help would be appreciated!

ehime
  • 8,025
  • 14
  • 51
  • 110
  • Don't you also want to tell the customer somewhere that they're being charged extra as a line item in their order? – random May 04 '11 at 21:26

1 Answers1

1

Is there a "session_start()" somewhere in this script prior to these lines?

session_start();
$_SESSION['cart']->total += 20;

Also, you might not want to put it right in the total. I'd put it in a shipping related variable, as well as add it to the running total. That way you can make sure you don't add it again if you've already done it once! Like:

session_start();
if (!$_SESSION['cart']->shipping_extra) {
  $_SESSION['cart']->shipping_extra = true;
  $_SESSION['cart']->total += 20;
}

Also... # is deprecated, use // or /* !

David Fells
  • 6,678
  • 1
  • 22
  • 34