I have a fresh install of Zen Cart v1.5.1 and I have installed the minimum checkout information mod and the minimum order mod. Both working fine, except the minimum order mod, which seems to only work for the total shopping cart value and does not take into account Coupon discounts etc.
I need to have a minimum order amount after all the deductions, as I can not have people checking out with R1 using a credit card and the banking charges to process this transaction cost me R3.
I tried modifying the minimum order mod includes/classes/observers.class.minimum_order_amount.php to the following (I had to put a >0 as I am happy for the customers to checkout with a 0 value, I just want to make sure my banking charges are covered so have to set a minium of say R5.) and I tried to use the global $order value, but this does not seem to give the value less deductions? Please assist me in this regard!
Code:<?php /** * class.minimum_order_amount.php * * @copyright Copyright 2005-2007 Andrew Berezin eCommerce-Service.com * @copyright Portions Copyright 2003-2006 Zen Cart Development Team * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 * @version $Id: config.minimum_order_amount.php 1.0.1 20.09.2007 0:06 AndrewBerezin $ */ /** * Observer class used to check minimum order amount * */ class minimum_order_amount extends base { /** * constructor method * * Attaches our class to the ... and watches for 4 notifier events. */ function minimum_order_amount() { global $zco_notifier; // $_SESSION['cart']->attach($this, array('NOTIFIER_CART_GET_PRODUCTS_START', 'NOTIFIER_CART_GET_PRODUCTS_END')); $zco_notifier->attach($this, array('NOTIFY_HEADER_END_SHOPPING_CART', 'NOTIFY_HEADER_START_CHECKOUT_SHIPPING', 'NOTIFY_HEADER_END_CHECKOUT_PAYMENT', 'NOTIFY_HEADER_START_CHECKOUT_CONFIRMATION', 'NOTIFY_HEADER_END_CHECKOUT_CONFIRMATION')); } /** * Update Method * * Called by observed class when any of our notifiable events occur * * @param object $class * @param string $eventID */ function update(&$class, $eventID) { global $db, $order, $currencies, $messageStack, $credit_covers; $TotalValue = 0; if (sizeof($order->products) < 1) { $TotalValue = $_SESSION['cart']->show_total(); } else { $TotalValue = $order->info['total']; } switch ($eventID) { case 'NOTIFIER_CART_GET_PRODUCTS_END': case 'NOTIFY_HEADER_END_SHOPPING_CART': if (isset($_SESSION['customer_id'])){ $prevOrders = $db->Execute("SELECT count(orders_id) total_orders FROM ".TABLE_ORDERS." WHERE customers_id = ".(int)$_SESSION['customer_id']); if ((int)$prevOrders->fields['total_orders'] == 0) { if ($_SESSION['cart']->count_contents() > 0 && MIN_FIRST_ORDER_AMOUNT > 0) { if(($TotalValue < MIN_FIRST_ORDER_AMOUNT) && $TotalValue>0){ $_SESSION['valid_to_checkout'] = false; $messageStack->add('shopping_cart', sprintf(TEXT_FIRST_ORDER_UNDER_MIN_AMOUNT, $currencies->format(MIN_FIRST_ORDER_AMOUNT)) . '<br />', 'caution'); } } } else { if ($_SESSION['cart']->count_contents() > 0 && MIN_ORDER_AMOUNT > 0) { if($TotalValue < MIN_ORDER_AMOUNT && $TotalValue>0) { $_SESSION['valid_to_checkout'] = false; $messageStack->add('shopping_cart', sprintf(TEXT_ORDER_UNDER_MIN_AMOUNT, $currencies->format(MIN_ORDER_AMOUNT)) . '<br />', 'caution'); } } } } else { if ($_SESSION['cart']->count_contents() > 0 && MIN_ORDER_AMOUNT > 0) { if($TotalValue < MIN_ORDER_AMOUNT && $TotalValue>0) { $_SESSION['valid_to_checkout'] = false; $messageStack->add('shopping_cart', sprintf(TEXT_ORDER_UNDER_MIN_AMOUNT, $currencies->format(MIN_ORDER_AMOUNT)) . '<br />', 'caution'); } } } break; case 'NOTIFY_HEADER_START_CHECKOUT_SHIPPING': case 'NOTIFY_HEADER_END_CHECKOUT_PAYMENT': case 'NOTIFY_HEADER_END_CHECKOUT_CONFIRMATION': case 'NOTIFY_CHECKOUT_PROCESS_AFTER_ORDER_TOTALS_PROCESS': if (isset($_SESSION['customer_id'])){ $prevOrders = $db->Execute("SELECT count(orders_id) total_orders FROM ".TABLE_ORDERS." WHERE customers_id = ".(int)$_SESSION['customer_id']); if ((int)$prevOrders->fields['total_orders'] == 0) { if ($_SESSION['cart']->count_contents() > 0 && MIN_FIRST_ORDER_AMOUNT > 0) { if($TotalValue < MIN_FIRST_ORDER_AMOUNT && $TotalValue>0) { zen_redirect(zen_href_link(FILENAME_SHOPPING_CART)); } } } else { if ($_SESSION['cart']->count_contents() > 0 && MIN_ORDER_AMOUNT > 0) { if($TotalValue < MIN_ORDER_AMOUNT && $TotalValue>0) { zen_redirect(zen_href_link(FILENAME_SHOPPING_CART)); } } } } else { if ($_SESSION['cart']->count_contents() > 0 && MIN_ORDER_AMOUNT > 0) { if($TotalValue < MIN_ORDER_AMOUNT && $TotalValue>0) { zen_redirect(zen_href_link(FILENAME_SHOPPING_CART)); } } } break; default: break; } } } ?>


Reply With Quote
