Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Seperate Pricing Per Customer v3.5


scendent

Recommended Posts

Hello!

 

Hoping for some help. I have been working on this for days now, reading - trying, reading some more - trying some more. I cannot get the Wholesale/group Specials Price to work properly.

 

I have implemented the fixes in posts 916 & 919, and still it does not work properly.

 

Wholesale special price works if there is no retail special price for the same product.

 

If there is both a wholesale & a retail price for the same product:

 

With NO login: specials retail price works

With login: specials retail price works (for customer not assigned to wholesale)

 

With login: specials wholesale price does NOT work (for customer assigned to wholesale)

(shows up in the product info page with the wholesale price crossed out, and the special price as the retail specials price)

 

Any advice/help would be much appreciated.

 

Thanks in advance.

 

Carlos

 

Here is a copy of my admin/specials.php file, which should be just the file from the 4.1.1 contribution with the 2 fixes:

 

<?php
/*
 $Id: specials.php,v 1.41 2003/06/29 22:50:52 hpdl Exp $
 adapted for Separate Pricing Per Customer v3.6 2005/01/29

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

 require(DIR_WS_CLASSES . 'currencies.php');
 $currencies = new currencies();
 
// BOF Separate Pricing Per Customer 
     $customers_groups_query = tep_db_query("select customers_group_name, customers_group_id from " . TABLE_CUSTOMERS_GROUPS . " order by customers_group_id ");
   while ($existing_groups =  tep_db_fetch_array($customers_groups_query)) {
        $input_groups[] = array("id"=>$existing_groups['customers_group_id'], "text"=> $existing_groups['customers_group_name']);
       $all_groups[$existing_groups['customers_group_id']]=$existing_groups['customers_group_name'];
   }
// EOF Separate Pricing Per Customer

 $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');

 if (tep_not_null($action)) {
   switch ($action) {
     case 'setflag':
       tep_set_specials_status($HTTP_GET_VARS['id'], $HTTP_GET_VARS['flag']);

       tep_redirect(tep_href_link(FILENAME_SPECIALS, (isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] . '&' : '') . 'sID=' . $HTTP_GET_VARS['id'], 'NONSSL'));
       break;
     case 'insert':
       $products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);
       $products_price = tep_db_prepare_input($HTTP_POST_VARS['products_price']);
       $specials_price = tep_db_prepare_input($HTTP_POST_VARS['specials_price']);
       $day = tep_db_prepare_input($HTTP_POST_VARS['day']);
       $month = tep_db_prepare_input($HTTP_POST_VARS['month']);
       $year = tep_db_prepare_input($HTTP_POST_VARS['year']);
// BOF Separate Pricing Per Customer
       $customers_group=tep_db_prepare_input($HTTP_POST_VARS['customers_group']);
       $price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS. " WHERE products_id = ".(int)$products_id . " AND customers_group_id  = ".(int)$customers_group);
       while ($gprices = tep_db_fetch_array($price_query)) {
           $products_price = $gprices['customers_group_price'];
       }

       if (substr($specials_price, -1) == '%' && $customers_group == '0') {
        $new_special_insert_query = tep_db_query("select products_id, products_price from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
        $new_special_insert = tep_db_fetch_array($new_special_insert_query);

        $products_price = $new_special_insert['products_price'];
        $specials_price = ($products_price - (($specials_price / 100) * $products_price));
      } elseif (substr($specials_price, -1) == '%' && $customers_group != '0') {
$specials_price = ($products_price - (($specials_price / 100) * $products_price));
}
// EOF Separate Pricing Per Customer
       $expires_date = '';
       if (tep_not_null($day) && tep_not_null($month) && tep_not_null($year)) {
         $expires_date = $year;
         $expires_date .= (strlen($month) == 1) ? '0' . $month : $month;
         $expires_date .= (strlen($day) == 1) ? '0' . $day : $day;
       }
// BOF Separate Pricing Per Customer
/*        tep_db_query("insert into " . TABLE_SPECIALS . " (products_id, specials_new_products_price, specials_date_added, expires_date, status) values ('" . (int)$products_id . "', '" . tep_db_input($specials_price) . "', now(), '" . tep_db_input($expires_date) . "', '1')"); */
   tep_db_query("insert into " . TABLE_SPECIALS . " (products_id, specials_new_products_price, specials_date_added, expires_date, status, customers_group_id) values ('" . (int)$products_id . "', '" . tep_db_input($specials_price) . "', now(), '" . tep_db_input($expires_date) . "', '1', ".(int)$customers_group.")");
// EOF Separate Pricing Per Customer
       tep_redirect(tep_href_link(FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page']));
       break;
     case 'update':
       $specials_id = tep_db_prepare_input($HTTP_POST_VARS['specials_id']);
       $products_price = tep_db_prepare_input($HTTP_POST_VARS['products_price']);
       $specials_price = tep_db_prepare_input($HTTP_POST_VARS['specials_price']);
       $day = tep_db_prepare_input($HTTP_POST_VARS['day']);
       $month = tep_db_prepare_input($HTTP_POST_VARS['month']);
       $year = tep_db_prepare_input($HTTP_POST_VARS['year']);

       if (substr($specials_price, -1) == '%') $specials_price = ($products_price - (($specials_price / 100) * $products_price));

       $expires_date = '';
       if (tep_not_null($day) && tep_not_null($month) && tep_not_null($year)) {
         $expires_date = $year;
         $expires_date .= (strlen($month) == 1) ? '0' . $month : $month;
         $expires_date .= (strlen($day) == 1) ? '0' . $day : $day;
       }

       tep_db_query("update " . TABLE_SPECIALS . " set specials_new_products_price = '" . tep_db_input($specials_price) . "', specials_last_modified = now(), expires_date = '" . tep_db_input($expires_date) . "' where specials_id = '" . (int)$specials_id . "'");

       tep_redirect(tep_href_link(FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page'] . '&sID=' . $specials_id));
       break;
     case 'deleteconfirm':
       $specials_id = tep_db_prepare_input($HTTP_GET_VARS['sID']);

       tep_db_query("delete from " . TABLE_SPECIALS . " where specials_id = '" . (int)$specials_id . "'");

       tep_redirect(tep_href_link(FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page']));
       break;
   }
 }
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
<?php
 if ( ($action == 'new') || ($action == 'edit') ) {
?>
<link rel="stylesheet" type="text/css" href="includes/javascript/calendar.css">
<script language="JavaScript" src="includes/javascript/calendarcode.js"></script>
<?php
 }
?>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">
<div id="popupcalendar" class="text"></div>
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
 <tr>
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
   </table></td>
<!-- body_text //-->
   <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
     <tr>
       <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
           <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
         </tr>
       </table></td>
     </tr>
<?php
 if ( ($action == 'new') || ($action == 'edit') ) {
   $form_action = 'insert';
   if ( ($action == 'edit') && isset($HTTP_GET_VARS['sID']) ) {
     $form_action = 'update';
// BOF Separate Pricing Per Customer
    $product_query = tep_db_query("select p.products_id, pd.products_name, p.products_price, s.specials_new_products_price, s.expires_date, s.customers_group_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = s.products_id and s.specials_id = '" . (int)$HTTP_GET_VARS['sID'] . "'");

    $product = tep_db_fetch_array($product_query);
    
    $customer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . $product['products_id']. "' and customers_group_id =  '" . $product['customers_group_id'] . "'");
       if ($customer_group_price = tep_db_fetch_array($customer_group_price_query)) {
          $product['products_price']= $customer_group_price['customers_group_price'];
       }
// EOF Separate Pricing Per Customer 
    $sInfo = new objectInfo($product);
   } else {
     $sInfo = new objectInfo(array());

// create an array of products on special, which will be excluded from the pull down menu of products
// (when creating a new product on special)
// BOF Separate Pricing Per Customer
/*      $specials_array = array();
     $specials_query = tep_db_query("select p.products_id from " . TABLE_PRODUCTS . " p, " . TABLE_SPECIALS . " s where s.products_id = p.products_id");
     while ($specials = tep_db_fetch_array($specials_query)) {
       $specials_array[] = $specials['products_id'];
     }
   } */
   $specials_array = array();
   $specials_query = tep_db_query("select p.products_id, s.customers_group_id from " .  TABLE_PRODUCTS . " p, " . TABLE_SPECIALS . " s where s.products_id = p.products_id");
   while ($specials = tep_db_fetch_array($specials_query)) {
      $specials_array[] = (int)$specials['products_id'].":".(int)$specials['customers_group_id'];
   }

   if(isset($HTTP_GET_VARS['sID']) && $sInfo->customers_group_id!= '0'){
       $customer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . $sInfo->products_id . "' and customers_group_id =  '" . $sInfo->customers_group_id . "'");
         if ($customer_group_price = tep_db_fetch_array($customer_group_price_query)) {
           $sInfo->products_price = $customer_group_price['customers_group_price'];
         }
   }
   } 
// EOF Separate Pricing Per Customer
?>
     <tr><form name="new_special" <?php echo 'action="' . tep_href_link(FILENAME_SPECIALS, tep_get_all_get_params(array('action', 'info', 'sID')) . 'action=' . $form_action, 'NONSSL') . '"'; ?> method="post"><?php if ($form_action == 'update') echo tep_draw_hidden_field('specials_id', $HTTP_GET_VARS['sID']); ?>
       <td><br><table border="0" cellspacing="0" cellpadding="2">
         <tr>
           <td class="main"><?php echo TEXT_SPECIALS_PRODUCT; ?> </td>
           <td class="main"><?php echo (isset($sInfo->products_name)) ? $sInfo->products_name . ' <small>(' . $currencies->format($sInfo->products_price) . ')</small>' : tep_draw_products_pull_down('products_id', 'style="font-size:10px"', $specials_array); echo tep_draw_hidden_field('products_price', (isset($sInfo->products_price) ? $sInfo->products_price : '')); ?></td>
         </tr>
<!-- BOF Separate Pricing per Customer -->
         <tr>
           <td class="main"><?php echo TEXT_SPECIALS_GROUPS; ?> </td>
           <td class="main"><?php if (isset($sInfo->customers_group_id)) {
           for ($x=0; $x<count($input_groups); $x++) {
           if ($input_groups[$x]['id'] == $sInfo->customers_group_id) {
           echo $input_groups[$x]['text'];
           }
           } // end for loop
           } else {
        echo tep_draw_pull_down_menu('customers_group', $input_groups, (isset($sInfo->customers_group_id)?$sInfo->customers_group_id:'')); 
        } ?> </td>
         </tr>
<!-- EOF Separate Pricing per Customer -->
         <tr>
           <td class="main"><?php echo TEXT_SPECIALS_SPECIAL_PRICE; ?> </td>
           <td class="main"><?php echo tep_draw_input_field('specials_price', (isset($sInfo->specials_new_products_price) ? $sInfo->specials_new_products_price : '')); ?></td>
         </tr>
         <tr>
           <td class="main"><?php echo TEXT_SPECIALS_EXPIRES_DATE; ?> </td>
           <td class="main"><?php echo tep_draw_input_field('day', (isset($sInfo->expires_date) ? substr($sInfo->expires_date, 8, 2) : ''), 'size="2" maxlength="2" class="cal-TextBox"') . tep_draw_input_field('month', (isset($sInfo->expires_date) ? substr($sInfo->expires_date, 5, 2) : ''), 'size="2" maxlength="2" class="cal-TextBox"') . tep_draw_input_field('year', (isset($sInfo->expires_date) ? substr($sInfo->expires_date, 0, 4) : ''), 'size="4" maxlength="4" class="cal-TextBox"'); ?><a class="so-BtnLink" href="javascript:calClick();return false;" onmouseover="calSwapImg('BTN_date', 'img_Date_OVER',true);" onmouseout="calSwapImg('BTN_date', 'img_Date_UP',true);" onclick="calSwapImg('BTN_date', 'img_Date_DOWN');showCalendar('new_special','dteWhen','BTN_date');return false;"><?php echo tep_image(DIR_WS_IMAGES . 'cal_date_up.gif', 'Calendar', '22', '17', 'align="absmiddle" name="BTN_date"'); ?></a></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
         <tr>
           <td class="main"><br><?php echo TEXT_SPECIALS_PRICE_TIP; ?></td>
           <td class="main" align="right" valign="top"><br><?php echo (($form_action == 'insert') ? tep_image_submit('button_insert.gif', IMAGE_INSERT) : tep_image_submit('button_update.gif', IMAGE_UPDATE)). '   <a href="' . tep_href_link(FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page'] . (isset($HTTP_GET_VARS['sID']) ? '&sID=' . $HTTP_GET_VARS['sID'] : '')) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
         </tr>
       </table></td>
     </form></tr>
<?php
 } else {
?>
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
             <tr class="dataTableHeadingRow">
               <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS; ?></td>
               <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_PRODUCTS_PRICE; ?></td>
               <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_STATUS; ?></td>
               <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td>
             </tr>
<?php
// BOF Separate Pricing Per Customer
/*    $specials_query_raw = "select p.products_id, pd.products_name, p.products_price, s.specials_id, s.specials_new_products_price, s.specials_date_added, s.specials_last_modified, s.expires_date, s.date_status_change, s.status from " . TABLE_PRODUCTS . " p, " . TABLE_SPECIALS . " s, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = s.products_id order by pd.products_name"; */
   $all_groups = array();
   $customers_groups_query = tep_db_query("select customers_group_name, customers_group_id from " . TABLE_CUSTOMERS_GROUPS . " order by customers_group_id ");
   while ($existing_groups =  tep_db_fetch_array($customers_groups_query)) {
     $all_groups[$existing_groups['customers_group_id']] = $existing_groups['customers_group_name'];
   }

  $specials_query_raw = "select p.products_id, pd.products_name, p.products_price, s.specials_id, s.customers_group_id, s.specials_new_products_price, s.specials_date_added, s.specials_last_modified, s.expires_date, s.date_status_change, s.status from " . TABLE_PRODUCTS . " p, " . TABLE_SPECIALS . " s, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = s.products_id order by pd.products_name"; 
  
  $customers_group_prices_query = tep_db_query("select s.products_id, s.customers_group_id, pg.customers_group_price from " . TABLE_SPECIALS . " s LEFT JOIN " . TABLE_PRODUCTS_GROUPS . " pg using (products_id, customers_group_id) ");

while ($_customers_group_prices = tep_db_fetch_array($customers_group_prices_query)) {
$customers_group_prices[] = $_customers_group_prices;
} 

   $specials_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $specials_query_raw, $specials_query_numrows);
   $specials_query = tep_db_query($specials_query_raw);
// BOF Separate Pricing Per Customer
   $no_of_rows_in_specials = tep_db_num_rows($specials_query);
   while ($specials = tep_db_fetch_array($specials_query)) {
   for ($y = 0; $y < $no_of_rows_in_specials; $y++) {
   if ( tep_not_null($customers_group_prices[$y]['customers_group_price']) && $customers_group_prices[$y]['products_id'] == $specials['products_id'] && $customers_group_prices[$y]['customers_group_id'] == $specials['customers_group_id']) {
   $specials['products_price'] = $customers_group_prices[$y]['customers_group_price'];
   } // end if (tep_not_null($customers_group_prices[$y]['customers_group_price'] etcetera
   } // end for loop
// EOF Separate Pricing Per Customer
     if ((!isset($HTTP_GET_VARS['sID']) || (isset($HTTP_GET_VARS['sID']) && ($HTTP_GET_VARS['sID'] == $specials['specials_id']))) && !isset($sInfo)) {
       $products_query = tep_db_query("select products_image from " . TABLE_PRODUCTS . " where products_id = '" . (int)$specials['products_id'] . "'");
       $products = tep_db_fetch_array($products_query);
       $sInfo_array = array_merge($specials, $products);
       $sInfo = new objectInfo($sInfo_array);
     }

     if (isset($sInfo) && is_object($sInfo) && ($specials['specials_id'] == $sInfo->specials_id)) {
       echo '                  <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page'] . '&sID=' . $sInfo->specials_id . '&action=edit') . '\'">' . "\n";
     } else {
       echo '                  <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page'] . '&sID=' . $specials['specials_id']) . '\'">' . "\n";
     }
?>
               <td  class="dataTableContent"><?php echo $specials['products_name']; ?></td>
<!-- BOF Separate Pricing Per Customer -->
               <td  class="dataTableContent" align="right"><span class="oldPrice"><?php echo $currencies->format($specials['products_price']); ?></span> <span class="specialPrice"><?php echo $currencies->format($specials['specials_new_products_price'])." (".$all_groups[$specials['customers_group_id']].")"; ?></span></td>
<!-- EOF Separate Pricing per Customer -->

               <td  class="dataTableContent" align="right">
<?php
     if ($specials['status'] == '1') {
       echo tep_image(DIR_WS_IMAGES . 'icon_status_green.gif', IMAGE_ICON_STATUS_GREEN, 10, 10) . '  <a href="' . tep_href_link(FILENAME_SPECIALS, 'action=setflag&flag=0&id=' . $specials['specials_id'], 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_red_light.gif', IMAGE_ICON_STATUS_RED_LIGHT, 10, 10) . '</a>';
     } else {
       echo '<a href="' . tep_href_link(FILENAME_SPECIALS, 'action=setflag&flag=1&id=' . $specials['specials_id'], 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_green_light.gif', IMAGE_ICON_STATUS_GREEN_LIGHT, 10, 10) . '</a>  ' . tep_image(DIR_WS_IMAGES . 'icon_status_red.gif', IMAGE_ICON_STATUS_RED, 10, 10);
     }
?></td>
               <td class="dataTableContent" align="right"><?php if (isset($sInfo) && is_object($sInfo) && ($specials['specials_id'] == $sInfo->specials_id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page'] . '&sID=' . $specials['specials_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td>
     </tr>
<?php
   }
?>
             <tr>
               <td colspan="4"><table border="0" width="100%" cellpadding="0"cellspacing="2">
                 <tr>
                   <td class="smallText" valign="top"><?php echo $specials_split->display_count($specials_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_SPECIALS); ?></td>
                   <td class="smallText" align="right"><?php echo $specials_split->display_links($specials_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page']); ?></td>
                 </tr>
<?php
 if (empty($action)) {
?>
                 <tr>
                   <td colspan="2" align="right"><?php echo '<a href="' . tep_href_link(FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page'] . '&action=new') . '">' . tep_image_button('button_new_product.gif', IMAGE_NEW_PRODUCT) . '</a>'; ?></td>
                 </tr>
<?php
 }
?>
               </table></td>
             </tr>
           </table></td>
<?php
 $heading = array();
 $contents = array();

 switch ($action) {
   case 'delete':
     $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_SPECIALS . '</b>');

     $contents = array('form' => tep_draw_form('specials', FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page'] . '&sID=' . $sInfo->specials_id . '&action=deleteconfirm'));
     $contents[] = array('text' => TEXT_INFO_DELETE_INTRO);
     $contents[] = array('text' => '<br><b>' . $sInfo->products_name . '</b>');
     $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . tep_href_link(FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page'] . '&sID=' . $sInfo->specials_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
     break;
   default:
     if (is_object($sInfo)) {
       $heading[] = array('text' => '<b>' . $sInfo->products_name . '</b>');

       $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page'] . '&sID=' . $sInfo->specials_id . '&action=edit') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page'] . '&sID=' . $sInfo->specials_id . '&action=delete') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a>');
       $contents[] = array('text' => '<br>' . TEXT_INFO_DATE_ADDED . ' ' . tep_date_short($sInfo->specials_date_added));
       $contents[] = array('text' => '' . TEXT_INFO_LAST_MODIFIED . ' ' . tep_date_short($sInfo->specials_last_modified));
       $contents[] = array('align' => 'center', 'text' => '<br>' . tep_info_image($sInfo->products_image, $sInfo->products_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT));
       $contents[] = array('text' => '<br>' . TEXT_INFO_ORIGINAL_PRICE . ' ' . $currencies->format($sInfo->products_price));
       $contents[] = array('text' => '' . TEXT_INFO_NEW_PRICE . ' ' . $currencies->format($sInfo->specials_new_products_price));
       $contents[] = array('text' => '' . TEXT_INFO_PERCENTAGE . ' ' . number_format(100 - (($sInfo->specials_new_products_price / $sInfo->products_price) * 100)) . '%');

       $contents[] = array('text' => '<br>' . TEXT_INFO_EXPIRES_DATE . ' <b>' . tep_date_short($sInfo->expires_date) . '</b>');
       $contents[] = array('text' => '' . TEXT_INFO_STATUS_CHANGE . ' ' . tep_date_short($sInfo->date_status_change));
     }
     break;
 }
 if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
   echo '            <td width="25%" valign="top">' . "\n";

   $box = new box;
   echo $box->infoBox($heading, $contents);

   echo '            </td>' . "\n";
 }
}
?>
         </tr>
       </table></td>
     </tr>
   </table></td>
<!-- body_text_eof //-->
 </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

Link to comment
Share on other sites

Hello!

 

Hoping for some help. I have been working on this for days now, reading - trying, reading some more - trying some more. I cannot get the Wholesale/group Specials Price to work properly.

 

I have implemented the fixes in posts 916 & 919, and still it does not work properly.

 

Wholesale special price works if there is no retail special price for the same product.

 

If there is both a wholesale & a retail price for the same product:

 

With NO login: specials retail price works

With login: specials retail price works (for customer not assigned to wholesale)

 

With login: specials wholesale price does NOT work (for customer assigned to wholesale)

(shows up in the product info page with the wholesale price crossed out, and the special price as the retail specials price)

 

Any advice/help would be much appreciated.

 

Thanks in advance.

 

Carlos

 

You have to create a special for the same product for each group. If you want to create a special for the product XYZ, you have to do it for the retail group and the wholesale group, do you have done this ? Check this out....

John

--------------------

osCommerce 2.3.4 Bootstrap Edge

Link to comment
Share on other sites

Thanks for replying.

 

Yes, I have a special created for for both retail & wholesale, which are the two groups I have.

 

The retail special works as it should, when either there is no login or when there is a login from a retail customer.

 

The wholesale does not work, it does as I described above in my first post for advice/help.

 

Carlos

 

As a footnote: everything works just fine if I only have one special created (either retail or wholesale)

Link to comment
Share on other sites

As a footnote: everything works just fine if I only have one special created (either retail or wholesale)

Strange... Does it only show the wrong price on the product_info.php page or also on the index page of the category, the price when you add it to the shopping cart etc.

 

My point being: you need to be determine whether the price is wrong in the database, or is the price wrongly displayed on a certain page?

Link to comment
Share on other sites

Hello,

 

I apologize for my footnote above as it is not correct - as you implied, if I only have a special created for 1 group it does not work properly. However I did/do have specials created for the same product for the two groups I have - and it doesn't work properly.

Link to comment
Share on other sites

if I only have a special created for 1 group it does not work properly. However I did/do have specials created for the same product for the two groups I have - and it doesn't work properly.

That doesn't shed any light on the problem.

 

Find out if there is a price for wholesale added to the database. If you see the price is wrong on the product_info page, add the article to the shopping basket and look at what the price is now. If the price is still wrong, good chance the correct price didn't go into the database (but then you woudn't expect to see a special "wrong" price for the wholesale customer so I expect it to be only wrong on the product_info page).

Link to comment
Share on other sites

Hello,

 

Thank you too for replying. I have nothing showing at the moment on the index page. Or anywhere else at the moment.

 

I have a huge amount of modified contributions, so I am taking this installation one step at a time. The firat step being to get it to show properly in the product_info.php and shopping cart. Then I figured, one by one I would address the issues that come up.

 

Presently, this incredibly useful contribution works fine with what I have tested so far, with the exception of the specials problem.

 

I have set group prices, testing with one group, and all seems okay so, far logged in or not logged in. ( I have for example not tested with gift vouchers, one of the many, many contributions I have installed)

 

Thanks,

 

Carlos

Link to comment
Share on other sites

I guess this means it is showing up wrong in the data base?

That seems a reasonable assumption. Do you also see the wrong price listed in the catalog/index.php?cPath=## page?

Can you check it with phpMyAdmin by looking at the specials table?

 

Edit: Of course you should see the wrong prices in the admin too. Do you?

Edited by JanZ
Link to comment
Share on other sites

I see now that when I use search engine friendly html setting, and force cookies setting (which is my preference) I get as I originally described.

 

However when I turn off search engine friendly html setting, and force cookies setting. I got the opposite - the wholesale login works properly but the retail does not. The retail shows the wholesale special price and carries it into the shopping cart.

 

I am going to take a look now at the data base now.

Link to comment
Share on other sites

Now I do see the correct prices in the admin panel. Before I implemented the 916 & 919 fixes the prices were incorrect in the admin panel.

That was so long ago, I already forgot about that... The search engine friendly url's of osC are a total disaster I understand. Don't use that. There are better ones, but you need to change the login page to use certain POST variables instead of GET variables (are not recognized after that change).

Personally, I don't see the advantage of those kind of URL's but that is just a personal opinion.

 

Perhaps something goes wrong with the logging off and logging in (I mean that the session variables that make osC recognize you as a retail or wholesale customer get mixed up).

 

You can check that by adding something to index.php (not visible for customers if this on a live site):

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<input type="hidden" value="<?php print_r($_SESSION); ?>
<!-- footer_eof //-->

Look for:

    [sppc_customer_group_id] => 1
   [sppc_customer_group_show_tax] => 0
   [sppc_customer_group_tax_exempt] => 1

Link to comment
Share on other sites

Hello again, and thanks agin for your time!

 

I am not sure what I am looking for in the data base.

 

What does seem a little strange is that there is a specials TABLE & a specials_retail_prices TABLE. That's it as far as specials go. Should there be a specials_wholesale_prices TABLE (as wholesale is my second group)?

 

There are two inserts in the specials TABLE - and for the specials_new_products_price the specials wholesale price is in one row and the specials retail price is in the other row.

 

And in the specials_retail_prices TABLE there is one insert - with the retail special price in the specials_new_products_price slot.

 

Does this tell you anything?

 

Carlos

Link to comment
Share on other sites

I am going to try your last suggestion. Presently though I am working with the search engine friendly setting off and the cookies forced off.

 

I tested with having removed the cookies in IE and also using opers, which is set to remove them after closing and there was still this problem.

 

Having the settings as I would like them is not anywhere near as important to me as having this contribution work, so I will continue now with the settings as you suggest.

Link to comment
Share on other sites


I added:

 

<!-- footer //-->

<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>

<input type="hidden" value="<?php print_r($_SESSION); ?>

<!-- footer_eof //-->

 

as you suggested.

 

I got nothing back concerning sppc.

 

Here's what showed up on my home page (it's not a live site - I removed the IP address):

 

<input type="hidden" value="Array ( [sESSION_IP_ADDRESS] => xx.xxx.xxx.xx [cart] => shoppingcart Object ( [contents] => Array ( ) [total] => 0 [weight] => 0 [content_type] => ) [language] => english [languages_id] => 1 [currency] => USD [navigation] => navigationhistory Object ( [path] => Array ( [0] => Array (

Link to comment
Share on other sites

What does seem a little strange is that there is a specials TABLE & a specials_retail_prices TABLE. That's it as far as specials go. Should there be a specials_wholesale_prices TABLE (as wholesale is my second group)?
No, there is only the specials_retail_prices. You don't need to bother about that table, it is updated automatically.

 

There are two inserts in the specials TABLE - and for the specials_new_products_price the specials wholesale price is in one row and the specials retail price is in the other row.
That sounds good.

 

And in the specials_retail_prices TABLE there is one insert - with the retail special price in the specials_new_products_price slot.
That is OK too.

 

Does this tell you anything?

That the prices in the database are OK. If there is a problem on a page there is (probably) something wrong with the code of that particular page then.
I got nothing back concerning sppc.
That means you are not logged-in. If you are logged-in you would and should see those sppc session variables.

I guess you need a few more characters: "">" to see it only in the source code of the page..

<input type="hidden" value="<?php print_r($_SESSION); ?>">

Link to comment
Share on other sites

I just discovered that I needed to be logged in, and as you stated I do get:

 

[sppc_customer_group_id] => 1

[sppc_customer_group_show_tax] => 1

[sppc_customer_group_tax_exempt] => 0

 

Now I am back to square 1, well almost.

 

As I now have the friendly search engine setting set to false, and the force cookies setting set to false - the created specials wholesale price shows up correctly, and goes into the shopping cart correctly.

 

But the created retail price (both when not logged in, and when logged in as a retail customer) shows up incorrectly in the products_info.php file, and passes on into the shopping cart incorrectly.

 

I am at a loss here.

 

Thanks for trying to help, it is so very much appreciated. Perhaps if something else comes to mind you will let me know.

 

Meanwhile I will keep plugging away at it - as it would well be worth the effort, to me, to get it working properly.

 

I'll be around.

 

Carlos

Link to comment
Share on other sites

I am at a loss here.

Me too to be frank. You did change this function in includes/functions/general.php?

// adapted for Separate Pricing Per Customer
 function tep_get_products_special_price($product_id) {
// BOF Separate Pricing Per Customer
 global $sppc_customer_group_id;
 
 if(!tep_session_is_registered('sppc_customer_group_id')) { 
 $customer_group_id = '0';
 } else {
    $customer_group_id = $sppc_customer_group_id;
 }
  
       $product_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$product_id . "' and status and customers_group_id = '" . (int)$customer_group_id . "'");
// EOF Separate_Pricing Per Customer

Link to comment
Share on other sites

Jan,

 

Okay then! This is where the problem was.

 

Instructions were:

 

**REPLACE**

$product_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$product_id . "' and status");

 

Only in my includes/functions/general.php I had:

 

$specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . $product_id . "' and status");

 

Followed by:

 

 if (tep_db_num_rows($specials_query)) {
     $special = tep_db_fetch_array($specials_query);
  $special_price = $special['specials_new_products_price'];
   } else {
  $special_price = false;
   }

 

So, I just added instead of replacing what the instructions said to replace, leaving the query that was already there in place.

 

When you asked about this in particular, I tried removing the $specials_query and replacing $product_query for $specials_query in the code below the original $specials_query that was there.

 

And it now works.

 

I have had to wing it, so to speak, as I am just knowledgeable enough to be dangerous.

 

There were, and are going to be still I'm sure, so many places in my modified files where the instructions for installing this incredibly huge, and also incredibly exciting SPPC contribution - did not come close to matching what I had.

 

When what choices I made in modifying the installation brought up errors (which there were many of), I had a leg to stand on. However when it just doesn't work, it makes figuring out why extremely difficult for me.

 

I am so sorry for getting you involved with all my customizing. Please know though, that I tried for days to figure this one out before coming here for help.

 

I have some 4 dozen or so contributions installed. Many having had to be modofied to fit together. As well, I have customized much of the checkout process, functionally and appearance wise - partly to see if I could, and partly because I did not like how it was. I am at this project for almost a year now. It is my hope to some day finish it.

 

Anyhow, now I am rambling, so I will stop.

 

Thanks again Jan

 

Regards,

 

Carlos

 

P.S. I hope you won't get annoyed when you see me back here looking for other answers, as surely I will be.

 

Have a great rest of your day there in your world!

Link to comment
Share on other sites

Jeep,

 

If you get a moment to elaborate, I am curious about what you implied earlier:

 

You have to create a special for the same product for each group. If you want to create a special for the product XYZ, you have to do it for the retail group and the wholesale group, do you have done this ? Check this out....

 

Now that the specials feature works as it should, I have done some testing and it seems that if I only create a special price for one group - it works fine, just as it should. I have tried it several times, alternating which group I used - and it works every which way I try it.

 

I marveled when having only a retail special price created, and while not being logged in, I was able to add to the shopping cart the product with the retail special price correctly showing and carrying over - then when checking out (using a wholesale account login), the final price was replaced by the wholesale price (which was less than the special retail price) when I got to the checkout confirmation page.

 

Anyways Jeep, at this point I am just sharing my small experiences with this marvelous contribution. Thanks again for responding. It is all much appreciated.

 

Regards,

 

Carlos

Link to comment
Share on other sites

I have some 4 dozen or so contributions installed. Many having had to be modofied to fit together. As well, I have customized much of the checkout process, functionally and appearance wise - partly to see if I could, and partly because I did not like how it was. I am at this project for almost a year now. It is my hope to some day finish it.
Not an easy task adding something as big as SPPC to this mix...
Have a great rest of your day there in your world!

Actually, I'm in the Netherlands, so I went to bed after my last post yesterday ;)
Link to comment
Share on other sites

Steve,

Backtracking the subject I think these would be correct instructions:

-------------------------
admin/customers.php

**REPLACE** line 824-833

 <td class="main"><?php if ($processed == true) {
   echo $cInfo->customers_group_id . tep_draw_hidden_field('customers_group_id');
 } else {	
 echo tep_draw_pull_down_menu('customers_group_id', $existing_customers_array, $cInfo->customers_group_id);
 } ?></td>
</tr>
<!-- EOF Separate Pricing per Customer -->
       </table></td>
     </tr>
<!-- BOF Separate Pricing per Customer --> 

**WITH**

<td class="main"><?php if ($processed == true) {
  echo $cInfo->customers_group_id . tep_draw_hidden_field('customers_group_id');
  // next line: additional modification
  echo tep_draw_hidden_field('old_customers_group_id');
} else { 
echo tep_draw_pull_down_menu('customers_group_id', $existing_customers_array, $cInfo->customers_group_id);
// next line: additional modification
echo tep_draw_hidden_field('old_customers_group_id', $cInfo->customers_group_id);
} ?></td>
</tr>
<!-- EOF Separate Pricing per Customer -->
      </table></td>
    </tr>
<!-- BOF Separate Pricing per Customer -->

**REPLACE** line 233

       tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', "customers_id = '" . (int)$customers_id . "' and address_book_id = '" . (int)$default_address_id . "'");

**WITH**

$old_customers_group_id = $_POST['old_customers_group_id'];
if ($old_customers_group_id <= 2 && $customers_group_id >= 3) {
   $sql_data_array_cg_ra = array('customers_group_ra' => '0'); //turn off RA light
          tep_db_perform(TABLE_CUSTOMERS, $sql_data_array_cg_ra, 'update', "customers_id = '" . (int)$customers_id . "'");
} // end if ($old_customers_group_id <= 2 && $customers_group_id >= 3)

     tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', "customers_id = '" . (int)$customers_id . "' and address_book_id = '" . (int)$default_address_id . "'");
     
if ($old_customers_group_id <= 2 && $customers_group_id >= 3) {
$name = $customers_firstname . " " . $customers_lastname;
// perhaps email_text should start with greeting: Dear mr./mrs " . $customers_lastname . ",\n\n
 $email_text = EMAIL_TEXT_WHOLESALER_APPROVAL;
 tep_mail($name, $customers_email_address, EMAIL_SUBJECT_WHOLESALER_APPROVAL, $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
} // end if ($old_customers_group_id <= 2 && $customers_group_id .>= 3)
-------------------------

NOTE1: ADD the defines for EMAIL_TEXT_WHOLESALER_APPROVAL and EMAIL_SUBJECT_WHOLESALER_APPROVAL

TO admin/includes/languages/english/customers.php

 

NOTE2: CHANGE: $old_customers_group_id <= 2 && $customers_group_id >= 3 TO YOUR PARTICULAR CASE

for example retail: 0, wholesale 1:

$old_customers_group_id < 1 && $customers_group_id >= 1

 

Jan,

 

Just a short note to pass on my thanks for the help. I'll let you know how I get on.

 

Best regards,

Steve

Link to comment
Share on other sites

Jeep,

 

If you get a moment to elaborate, I am curious about what you implied earlier:

Now that the specials feature works as it should, I have done some testing and it seems that if I only create a special price for one group - it works fine, just as it should. I have tried it several times, alternating which group I used - and it works every which way I try it.

 

I marveled when having only a retail special price created, and while not being logged in, I was able to add to the shopping cart the product with the retail special price correctly showing and carrying over - then when checking out (using a wholesale account login), the final price was replaced by the wholesale price (which was less than the special retail price) when I got to the checkout confirmation page.

 

Anyways Jeep,  at this point I am just sharing my small experiences with this marvelous contribution. Thanks again for responding. It is all much appreciated.

 

Regards,

 

Carlos

 

Thomas,

 

It's normal if you not login in and you add product to your cart at a retail price and special retail price and when you checkout, you have to login and if you login with a group other than retail price, your cart will be change with the group price you are attached to... It's the goal of the SPPC :D , it's the a great contribution, Hail to JanZ :thumbsup: . Have a nice day.

John

--------------------

osCommerce 2.3.4 Bootstrap Edge

Link to comment
Share on other sites

hi please help me im desparate

 

i have 2 groups "CONSUMER, MERCHANT",

what i want to do is after loging-in redirect the consumer to FILENAME_CONSUMER and if merchant to FILENAME_MERCHANT.

 

in login.php i found

        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);
       } else {
         tep_redirect(tep_href_link(FILENAME_DEFAULT));
       }
     }
   }
 }

but im not even sure if thats the right line to alter.

 

on this thread i found out that i can do something like this

http://www.oscommerce.com/forums/index.php?sho...=360&p=556240

 

          if ($customer_group_id != '0') { // retail is always '0'
            tep_redirect(tep_href_link(FILENAME_CONSUMER));
         } else {
            tep_redirect(tep_href_link(FILENAME_MERCHANT));
         }

 

how do i do it?

please help/advice

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...