Noting that this discount is not compatible with One-Page Checkout, since it looks at the total-orders' history based on the current customer's id ... and OPC re-uses the same customer-id for all guests' checkouts!
I'll suggest the following insertion to the order-total's constructor:
Code:
public function __construct() {
$this->code = 'ot_loyalty_discount';
$this->title = MODULE_LOYALTY_DISCOUNT_TITLE;
$this->description = MODULE_LOYALTY_DISCOUNT_DESCRIPTION;
$this->enabled = (defined('MODULE_LOYALTY_DISCOUNT_STATUS') && MODULE_LOYALTY_DISCOUNT_STATUS == 'true');
$this->sort_order = defined('MODULE_LOYALTY_DISCOUNT_SORT_ORDER') ? MODULE_LOYALTY_DISCOUNT_SORT_ORDER : null;
if (null === $this->sort_order) return false;
if (function_exists('zen_in_guest_checkout') && zen_in_guest_checkout()) return false;
$this->include_shipping = MODULE_LOYALTY_DISCOUNT_INC_SHIPPING;
$this->include_tax = MODULE_LOYALTY_DISCOUNT_INC_TAX;
$this->calculate_tax = MODULE_LOYALTY_DISCOUNT_CALC_TAX;
...
I didn't include the entire constructor, since one of the variable names was getting ###'d. That will correct the issue on the storefront, but not if the order-total is used in conjunction with Edit Orders.
Bookmarks