
Originally Posted by
Dave224
The notifier I'm using is NOTIFIER_CART_GET_PRODUCTS_START with checks on presence of $_SESSION['opc'], $_SESSION['opc']->isGuestCheckout() === true, and $_SESSION['opc']->getAddressLabelFields for the guest billing address. All this to get the first notifier occurrence after the guest's name and address is entered. This is followed by checks on the name and address against a separate table of customers who get discounts. Then the guest customer entry in table customers is updated with the guests pricing group. Finally, there's some code to set a $_SESSION variable to check to prevent repeating the processing for subsequent notifications because I couldn't get the detach notifier method to work. If the guest does not get a discount, the guest entry in table customers is returned to it's default. Not the easiest notifier, but it's the only one I could find to work with.
I think I see what you're suggesting. Basically, set the guest entry in the customer table to any pricing group so that ot_group_pricing calculates the discount, followed by checks there to see if the discount is valid for the current customer or guest and override if not valid. I would still have to eliminate the check on zen_in_guest_checkout() in method process in ot_group_pricing. Am I correct in understanding your suggestion?
Dave
What I'm suggesting is to add a notification in /includes/modules/order_total/ot_group_pricing.php's calculate_deductions method:
Code:
if ($order_total == 0 || !zen_is_logged_in() || zen_in_guest_checkout()) {
global $zco_notifier;
$zco_notifier->notify('NOTIFY_OT_GROUP_PRICING_DEDUCTION_OVERRIDE', ['order_total' => $order_total], $od_amount);
return $od_amount;
}
Your observer would watch for that notification and, if the 'order_total' isn't 0 and zen_in_guest_checkout() returns (bool)true, would check for the guest customer that you're looking to provide the deduction for and 'fill in' the $od_amount array with the discount information.