Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2005
    Location
    Finland
    Posts
    186
    Plugin Contributions
    1

    help question Doing a tax-included/excluded override based on customers group

    I'm trying to do a simple override, at least I thought so, to hide tax from prices for resellers.

    Tried adding a new file to 'includes/extra_configures', 'includes/extra_datafiles' etc. but it seems like $_SESSION['customer_id'] isn't loaded at this point? Wonder where I went wrong, and if anyone can get me back on track.

    Code:
    <?php
    
    // get customers group
    if($_SESSION['customer_id']) {
      global $db, $customers_group;
         $customer_group_query = "select gp.group_name
                                   from " . TABLE_CUSTOMERS . " cu
                                   left join " . TABLE_GROUP_PRICING . " gp on cu.customers_group_pricing=gp.group_id
                                   where cu.customers_id = " . $_SESSION['customer_id'];
          if($customer_group = $db->Execute($customer_group_query)) {
            $customers_group=$customer_group->fields['group_name'];
          }
    }
    
    // if reseller display prices ex tax
    if ($customers_group == 'Reseller') {
        define('DISPLAY_PRICE_WITH_TAX', 'false');
    }

  2. #2
    Join Date
    Jan 2004
    Posts
    66,450
    Plugin Contributions
    81

    Default Re: Doing a simple tax override based on customers group

    Two problems:
    1. The session isn't started yet
    2. By the time the session is started, you won't be able to define DISPLAY_PRICE_WITH_TAX to a different value, because it will already be defined
    .
    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Oct 2005
    Location
    Finland
    Posts
    186
    Plugin Contributions
    1

    Default Re: Doing a simple tax override based on customers group

    Thanks for your reply DrByte, I appreciate it.

    If I only have define('DISPLAY_PRICE_WITH_TAX', 'false'); in the file it will display all prices ex tax, but then it's for all - and of no use.

    I was hoping I wouldn't need to change lot's of core files to make this work, as the tax handling isn't fully centralized - seems like the define is used in 32 lines (15 files) in catalog part (+ plugins).

    Does anyone see any possible workaround for this, without requiring full rewrite/override of tax function and/or all those files?

  4. #4
    Join Date
    Jan 2004
    Posts
    66,450
    Plugin Contributions
    81

    Default Re: Doing a simple tax override based on customers group

    When the store is operating in "DISPLAY_PRICE_WITH_TAX = 'false'" mode, then it's easier to skip taxes because they're basically assessed by an order-total module, which can be disabled selectively.

    But when you're using DISPLAY_PRICE_WITH_TAX='true' mode, it's definitely more complicated.
    I suppose you could set a session cookie during login and put your earlier code (after changing it to read the cookie instead of the session) into an init script set to load at an autoloader point between 30 and 40 ... say maybe 37. When the cookie is set during login and the customer is redirected back to (whatever page in) the store, it could then read the cookie and take action accordingly.
    I'm not a big fan of using cookies for anything more than absolutely necessary, but technically it would probably accomplish your goal.
    .
    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  5. #5
    Join Date
    Oct 2005
    Location
    Finland
    Posts
    186
    Plugin Contributions
    1

    Default Re: Doing a simple tax override based on customers group

    OK, don't want to go into that cookie thing - so I just hacked the core files.

    Added to end of application_top.php
    Code:
    // get customers group
    if($_SESSION['customer_id']) {
      global $customers_group;
         $customer_group_query = "select gp.group_name
                                   from " . TABLE_CUSTOMERS . " cu
                                   left join " . TABLE_GROUP_PRICING . " gp on cu.customers_group_pricing=gp.group_id
                                   where cu.customers_id = " . $_SESSION['customer_id'];
          if($customer_group = $db->Execute($customer_group_query)) {
            $customers_group=$customer_group->fields['group_name'];
          }
    }
    And then changed all
    Code:
    DISPLAY_PRICE_WITH_TAX == 'true'
    into
    Code:
    DISPLAY_PRICE_WITH_TAX == 'true' && $customers_group != 'Reseller'

 

 

Similar Threads

  1. Replies: 16
    Last Post: 8 Jul 2010, 08:51 PM
  2. reopen thread [Done v1.3.9] Discount groups and tax calc problem with tax-included pr
    By antonios in forum Currencies & Sales Taxes, VAT, GST, etc.
    Replies: 3
    Last Post: 1 Jul 2010, 06:12 PM
  3. Replies: 26
    Last Post: 19 Mar 2010, 04:45 PM
  4. Subtracting tax from a set price: how do I do tax-included pricing?
    By willem in forum Currencies & Sales Taxes, VAT, GST, etc.
    Replies: 2
    Last Post: 3 May 2009, 08:34 AM
  5. Tax not being calculated correctly -- with tax-included pricing
    By nkrcs in forum Currencies & Sales Taxes, VAT, GST, etc.
    Replies: 2
    Last Post: 11 Jun 2008, 07:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg