I’m very close to set my e-commerce website project online, but I have an issue with a postage function. I’m using a plugin originally created by texnixe here : Commerce Plugin - interest? - #71 by texnixe, wich was upgraded by starckio in Cartkit : Shopping cart with PayPal!.
So, the template/controller and functions are exactly the same and everything works fine locally. But when I put the website on servor, the $postage
variable doesn’t return any value to the paypal page.
The example given by texnite has the same issue : https://kylebean.co.uk/shop. When you click “add to cart”, and then “pay with paypal”, the postage doesn’t appear in the form.
This is here the cart.php plugin
<?php
function get_cart() {
s::start();
$cart = s::get('cart', array());
return $cart;
}
function cart_logic($cart) {
if (isset($_REQUEST['action'])) {
$action = $_REQUEST['action'];
$id = $_REQUEST['id'];
switch ($action) {
case 'add':
if (isset($cart[$id])) {
$cart[$id]++;
} else {
$cart[$id] = 1;
}
break;
case 'remove':
if (isset($cart[$id])) {
$cart[$id]--;
} else {
$cart[$id] = 1;
}
break;
case 'update':
if (isset($_REQUEST['quantity'])) {
$quantity = intval($_REQUEST['quantity']);
if ($quantity < 1) {
unset($cart[$id]);
} else {
$cart[$id] = $quantity;
}
}
break;
case 'delete':
if (isset($cart[$id])) {
unset($cart[$id]);
}
break;
}
s::set('cart', $cart);
}
// if (count($cart) == 0) {
// go(url('products'));
// }
return $cart;
}
function cart_count($cart) {
$count = 0;
foreach ($cart as $id => $quantity) {
$count += $quantity;
}
return $count;
}
function cart_postage($total) {
$postage;
switch ($total) {
case ($total < 10):
$postage = 2.5;
break;
case ($total < 30):
$postage = 3.5;
break;
case ($total < 75):
$postage = 5.5;
break;
case ($total < 150):
$postage = 8;
break;
default:
$postage = 10;
}
return $postage;
}