Re: Bug: price manager adds Tax to the promotional price! Help needed...
Sorry for the delay.
So the truly zen way would be to write an observer to listen to: NOTIFY_HEADER_START_CHECKOUT_PAYMENT
In which the software would be something like:
Will be creating two files.
The first to go into includes/auto_loaders
Suggest giving it a name that has meaning to the task. Something like config.whole_sale_taxes.php
Code:
<?php /** * Autoloader array for products with attributes stock (SBA) functionality. Makes sure that products with attributes stock is instantiated at the * right point of the Zen Cart initsystem. * * @package whole_sale_taxes.php * @author mc12345678 * @copyright Copyright 2008-2015 mc12345678 * @copyright Copyright 2003-2007 Zen Cart Development Team * @copyright Portions Copyright 2003 osCommerce * @link
http://www.zen-cart.com/ * @license
http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 * @version $Id: config.whole_sale_taxes.php xxxx 2015-06-15 * * Modify the tax display of wholesale taxes */ $autoLoadConfig[0][] = array( 'autoType' => 'class', 'loadFile' => 'observers/class.whole_sale_taxes.php' ); $autoLoadConfig[199][] = array( 'autoType' => 'classInstantiate', 'className' => 'whole_sale_taxes', 'objectName' => 'whole_sale_taxes_observe' ); ?>
The second is the class file that functions as the observer, listening and waiting for the primary code to take some form of action to which this will take action.
Based on the above information the filename for this second file would be class.whole_sale_taxes.php and stored in the directory: includes/classes/observers
Code:
<?php /** * Description of class.whole_sale_taxes: This class is used to support tax information related to the wholesale module. This way reduces the modifications of the includes/modules/pages/checkout_payment/header_php.php and other files reached from that page to nearly nothing. * * @author mc12345678 * */ class whole_sale_taxes extends base { /* * This is the observer for the includes/modules/pages/checkout_payment/header_php.php file to support taxing everyone equally when the order is being processed at the end of the purchase. */ function whole_sale_taxes() { global $zco_notifier; $zco_notifier->attach($this, array('NOTIFY_HEADER_START_CHECKOUT_PAYMENT', 'NOTIFY_ORDER_PROCESSING_ATTRIBUTES_BEGIN', 'NOTIFY_HEADER_START_CHECKOUT_SHIPPING', 'NOTIFY_HEADER_START_CHECKOUT_SUCCESS', 'NOTIFY_HEADER_START_CHECKOUT_SHIPPING_ADDRESS', 'NOTIFY_HEADER_START_CHECKOUT_PROCESS', 'NOTIFY_HEADER_START_CHECKOUT_PAYMENT_ADDRESS', 'NOTIFY_HEADER_START_CHECKOUT_CONFIRMATION', 'NOTIFY_HEADER_START_SHOPPING_CART', 'NOTIFY_HEADER_START_LOGIN')); } /* * Generic function that is activated when any notifier identified in the observer is called but is not found in one of the updated methods of calling an observer (ZC 1.5.3+) is encountered as a notifier. */ function update(&$callingClass, $notifier, $paramsArray) { global $db; // remove the session variable that removes tax from the calculations. if ($notifier == 'NOTIFY_HEADER_START_CHECKOUT_PAYMENT'){ if ($_SESSION['customer_whole']=='1') { unset($_SESSION['customer_whole']); $_SESSION['customer_whole_reset']='1'; } } // restore the tax "discount" so that the customer continues to see the untaxed price until returning to the above page(s). if ($notifier == 'NOTIFY_ORDER_PROCESSING_ATTRIBUTES_BEGIN' || $notifier == 'NOTIFY_HEADER_START_CHECKOUT_SHIPPING' || $notifier == 'NOTIFY_HEADER_START_CHECKOUT_SUCCESS' || $notifier == 'NOTIFY_HEADER_START_CHECKOUT_SHIPPING_ADDRESS' || $notifier == 'NOTIFY_HEADER_START_CHECKOUT_PROCESS' || $notifier == 'NOTIFY_HEADER_START_CHECKOUT_PAYMENT_ADDRESS' || $notifier == 'NOTIFY_HEADER_START_CHECKOUT_CONFIRMATION' || $notifier == 'NOTIFY_HEADER_START_SHOPPING_CART' || $notifier == 'NOTIFY_HEADER_START_LOGIN') { if ($_SESSION['customer_whole_reset']=='1') { unset($_SESSION['customer_whole_reset']); $_SESSION['customer_whole']='1' } } } //end update function - mc12345678 } //end class - mc12345678 ?>
I believe I've overdone it a little in the second set of checks (to restore the condition back to where the customer is recognized as a wholesale customer) and may have missed an appropriate page, but, perhaps you get the jest.
So often I forget to put the additional notifiers to which to listen up at the declaration function... Get so carried away with the actions to be taken that I forget to tell the code to listen for the notifier. :)