Commit 992831c5 authored by Malcolm Blaney's avatar Malcolm Blaney

Don't add shipping for pickup, and display different content at

the end of the order email for pickup and non-pickup.
parent 5a2b8503
Pipeline #5176314 passed with stage
in 2 minutes and 1 second
......@@ -568,9 +568,6 @@ class Cart extends Base {
$total_price += $price * $quantity;
$total_weight += $weight * $quantity;
}
if ($method !== 'paypal') {
$item_names .= '</table>';
}
if ($first === '' || $last === '' || $email === '' || $address === '') {
$order_verified = false;
}
......@@ -578,12 +575,26 @@ class Cart extends Base {
$result = [];
if ($order_verified) {
// Look for shipping rules that match the given locations.
$rules = $this->ShippingRules($city, $state, $country, $total_weight);
$shipping = $this->ShippingCost($total_price, $rules);
$shipping = 0;
if ($method !== 'pickup') {
// Look for shipping rules that match the given locations.
$rules = $this->ShippingRules($city, $state, $country, $total_weight);
$shipping = $this->ShippingCost($total_price, $rules);
}
$result['shipping'] = $shipping;
$processing = $this->ProcessingCost($total_price);
$result['processing'] = $processing;
if ($method !== 'paypal') {
if ($shipping !== 0) {
$item_names .= '<tr><td>Shipping</td><td></td>'.
'<td>$'.number_format($shipping, 2, '.', '').'</td></tr>';
}
if ($processing !== 0) {
$item_names .= '<tr><td>Processing</td><td></td>'.
'<td>$'.number_format($processing, 2, '.', '').'</td></tr>';
}
$item_names .= '</table>';
}
if ($method === 'pickup') {
$order_id = $this->Payment($item_names, $total_price + $shipping +
$processing, $first, $last, $email, $address,
......@@ -1014,6 +1025,13 @@ class Cart extends Base {
$replacements = [$items, number_format($amount, 2, '.', ''), $first, $last,
$email, $address, $postcode, $city, $state, $country];
$us_email_text = $this->Substitute('cart-email', $patterns, $replacements);
if ($method === 'pickup') {
$us_email_text .= 'Your order will be available to pick up from: '.
$description;
}
else {
$us_email_text .= $this->Substitute('cart-delivery-info');
}
$query = 'INSERT INTO cart_order (user, email, description, method, '.
'timestamp) VALUES ("'.$this->owner.'", "'.$email.'", '.
'"'.$mysqli->escape_string($us_email_text).'", "'.$method.'", '.
......@@ -1032,8 +1050,7 @@ class Cart extends Base {
if ($method === 'pickup') {
$order_id = $_SESSION['cart-order-id'];
$this->SendEmail('Confirmation for order number '.$order_id,
$us_email_text.'Your order will be available to pick '.
'up from: '.$description, $email);
$us_email_text, $email);
return $order_id;
}
if ($method === 'paypal') {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment