Jump to content
Sign in to follow this  
lukechanning

SPPC - Not Loading sppc_customer_group_id Correctly

Recommended Posts

I've added Separate Pricing Per Customer to my OSC 2.3.4 installation, and it all works! Haven't had any problems with it so far, EXCEPT that it doesn't seem to be loading my Group Configuration settings. If I set a shipping / payment option for the customer specifically, it works fine. But none of my "Cash Account" customer settings are loading automatically from the group itself. 

 

When I print out the Session Variables, it shows that : 

[sppc_customer_group_id] = 0

but it should be 2! I cannot for the life of me figure out why this is. Anyone have any thoughts? I'm assuming the call for that variable isn't connecting properly, but I've checked everywhere I know to, and it all looks like it should work fine . . . All other session variables look correct! 

 

Pointers? Not asking for anyone to do the work for me, obviously, just trying to deconstruct and figure out why it would be behaving like that. 

 

 

Share this post


Link to post
Share on other sites

Fixed it! Stupid mistake on my part. Totally forgot to integrate the login.php changes, mostly because I moved past them due to the complexity the first time. Thankfully, it's been done now. So others can benefit, here's the changed code, minus the logging in with a certain category (don't need that for my site, sorry folks!)

<?php
/*
  $Id$


  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com


  Copyright (c) 2014 osCommerce


  Released under the GNU General Public License
*/


  require('includes/application_top.php');
  require(DIR_WS_FUNCTIONS . 'recaptchalib.php'); // reCAPTCHA


// redirect the customer to a friendly cookie-must-be-enabled page if cookies are disabled (or the session has not started)
  if ($session_started == false) {
    if ( !isset($HTTP_GET_VARS['cookie_test']) ) {
      $all_get = tep_get_all_get_params();


      tep_redirect(tep_href_link(FILENAME_LOGIN, $all_get . (empty($all_get) ? '' : '&') . 'cookie_test=1', 'SSL'));
    }


    tep_redirect(tep_href_link(FILENAME_COOKIE_USAGE));
  }


// login content module must return $login_customer_id as an integer after successful customer authentication
  $login_customer_id = false;


  $page_content = $oscTemplate->getContent('login');


  if ( is_int($login_customer_id) && ($login_customer_id > 0) ) {
    if (SESSION_RECREATE == 'True') {
      tep_session_recreate();
    }
    //BOF Changes - SPPC for OSC 2.3.4
    //$customer_info_query = tep_db_query("select c.customers_firstname, c.customers_default_address_id, ab.entry_country_id, ab.entry_zone_id from " . TABLE_CUSTOMERS . " c left join " . TABLE_ADDRESS_BOOK . " ab on (c.customers_id = ab.customers_id and c.customers_default_address_id = ab.address_book_id) where c.customers_id = '" . (int)$login_customer_id . "'");
    $customer_info_query = tep_db_query("select c.customers_firstname, c.customers_group_id, c.customers_specific_taxes_exempt, c.customers_default_address_id, ab.entry_country_id, ab.entry_zone_id from " . TABLE_CUSTOMERS . " c left join " . TABLE_ADDRESS_BOOK . " ab on (c.customers_id = ab.customers_id and c.customers_default_address_id = ab.address_book_id) where c.customers_id = '" . (int)$login_customer_id . "'");
    //END
    $customer_info = tep_db_fetch_array($customer_info_query);


    $customer_id = $login_customer_id;
    tep_session_register('customer_id');


    $customer_default_address_id = $customer_info['customers_default_address_id'];
    tep_session_register('customer_default_address_id');


    $customer_first_name = $customer_info['customers_firstname'];
    tep_session_register('customer_first_name');


    // BOF Separate Pricing Per Customer
    $customers_specific_taxes_exempt = $customer_info['customers_specific_taxes_exempt'];
    if ($_POST['skip'] == 'true' && $_POST['email_address'] == SPPC_TOGGLE_LOGIN_PASSWORD && isset($_POST['new_customers_group_id']))  {
      $sppc_customer_group_id = $_POST['new_customers_group_id'] ;
      $customer_info_group_tax = tep_db_query("select customers_group_show_tax, customers_group_tax_exempt, group_specific_taxes_exempt from " . TABLE_CUSTOMERS_GROUPS . " where customers_group_id = '" .(int)$_POST['new_customers_group_id'] . "'");
    } else {
      $sppc_customer_group_id = $customer_info['customers_group_id'];
      $customer_info_group_tax = tep_db_query("select customers_group_show_tax, customers_group_tax_exempt, group_specific_taxes_exempt from " . TABLE_CUSTOMERS_GROUPS . " where customers_group_id = '" .(int)$customer_info['customers_group_id'] . "'");
    }
    $customer_group_tax = tep_db_fetch_array($customer_info_group_tax);
    $sppc_customer_group_show_tax = (int)$customer_group_tax['customers_group_show_tax'];
    $sppc_customer_group_tax_exempt = (int)$customer_group_tax['customers_group_tax_exempt'];
    $group_specific_taxes_exempt = $customer_group_tax['group_specific_taxes_exempt'];
    if (tep_not_null($customers_specific_taxes_exempt)) {
      $sppc_customer_specific_taxes_exempt = $customers_specific_taxes_exempt;
    } elseif (tep_not_null($group_specific_taxes_exempt)) {
      $sppc_customer_specific_taxes_exempt = $group_specific_taxes_exempt;
    } else {
      $sppc_customer_specific_taxes_exempt = '';
    }
    // EOF Separate Pricing Per Customer


    // BOF Separate Pricing per Customer
      tep_session_register('sppc_customer_group_id');
      tep_session_register('sppc_customer_group_show_tax');
      tep_session_register('sppc_customer_group_tax_exempt');
      if (tep_not_null($sppc_customer_specific_taxes_exempt)) {
        tep_session_register('sppc_customer_specific_taxes_exempt');
      }
    // EOF Separate Pricing per Customer




    $customer_country_id = $customer_info['entry_country_id'];
    tep_session_register('customer_country_id');


    $customer_zone_id = $customer_info['entry_zone_id'];
    tep_session_register('customer_zone_id');


    tep_db_query("update " . TABLE_CUSTOMERS_INFO . " set customers_info_date_of_last_logon = now(), customers_info_number_of_logons = customers_info_number_of_logons+1, password_reset_key = null, password_reset_date = null where customers_info_id = '" . (int)$customer_id . "'");


// reset session token
    $sessiontoken = md5(tep_rand() . tep_rand() . tep_rand() . tep_rand());


// restore cart contents
    $cart->restore_contents();


    if (sizeof($navigation->snapshot) > 0) {
      $origin_href = tep_href_link($navigation->snapshot['page'], tep_array_to_string($navigation->snapshot['get'], array(tep_session_name())), $navigation->snapshot['mode']);
      $navigation->clear_snapshot();
      tep_redirect($origin_href);
    }


    tep_redirect(tep_href_link(FILENAME_DEFAULT));
  }


  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_LOGIN);


  $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_LOGIN, '', 'SSL'));


  require(DIR_WS_INCLUDES . 'template_top.php');
?>


<h1><?php echo HEADING_TITLE; ?></h1>


<?php
  if ($messageStack->size('login') > 0) {
    echo $messageStack->output('login');
  }
?>


<div id="loginModules">
  <?php echo $page_content; ?>
</div>


<script type="text/javascript">
var login_modules_counter = 0;
var login_modules_total = $('#loginModules .contentContainer').length;


$('#loginModules .contentContainer').each(function(index, element) {
  login_modules_counter++;


  if ( login_modules_counter == 1 ) {
    if ( $(this).hasClass('grid_8') && ((index+1) != login_modules_total) ) {
      $(this).addClass('alpha');
    } else {
      login_modules_counter = 0;
    }
  } else {
    if ( $(this).hasClass('grid_8') ) {
      $(this).addClass('omega');
    }


    login_modules_counter = 0;
  }
});
</script>


<?php
  require(DIR_WS_INCLUDES . 'template_bottom.php');
  require(DIR_WS_INCLUDES . 'application_bottom.php');
?>

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×