Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

separate pricing per customer products_new.php


Recommended Posts

Posted

Excellent Contribution!

 

However am having problems with products_new.php

My products_new.php is as follows:

 

  • <?php

/*

$Id: products_new.php,v 1.11 2003/02/12 23:55:58 hpdl Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

?>

<table border="0" width="100%" cellspacing="0" cellpadding="2">

<?php

if (sizeof($products_new_array) < 1) {

?>

<tr>

<td class="main"><?php echo TEXT_NO_NEW_PRODUCTS; ?></td>

</tr>

<?php

} else {

for($i=0, $n=sizeof($products_new_array); $i<$n; $i++) {

if (isset($products_new_array[$i]['specials_price'])) {

$products_price = '<s>' . $currencies->display_price($products_new_array[$i]['price'], tep_get_tax_rate($products_new_array[$i]['tax_class_id'])) . '</s>  <span class="productSpecialPrice">' . $currencies->display_price($products_new_array[$i]['specials_price'], tep_get_tax_rate($products_new_array[$i]['tax_class_id'])) . '</span>';

} else {

// separate pricing per customer replace the following

// $products_price = $currencies->display_price($products_new_array[$i]['price'], tep_get_tax_rate($products_new_array[$i]['tax_class_id']));

// with the following

global $customer_id;

$customer_group_query = tep_db_query("select customers_group_id from " . TABLE_CUSTOMERS . " where customers_id = '" . $customer_id . "'");

$customer_group = tep_db_fetch_array($customer_group_query);

$customer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . $products_new_array[$i]['id'] . "' and customers_group_id = '" . $customer_group['customers_group_id'] . "'");

if ( $customer_group['customers_group_id'] != 0) {

if ($customer_group_price = tep_db_fetch_array($customer_group_price_query)) {

$products_price = $currencies->display_price($customer_group_price['customers_group_price'], tep_get_tax_rate($products_new_array[$i]['tax_class_id']));

} else {

$products_price = $currencies->display_price($products_new_array[$i]['price'], tep_get_tax_rate($products_new_array[$i]['tax_class_id'])

}

} else {

$products_price = $currencies->display_price($products_new_array[$i]['price'], tep_get_tax_rate($products_new_array[$i]['tax_class_id'])

}

// end of separate pricing per customer replace

}

?>

<tr>

<td width="<?php echo SMALL_IMAGE_WIDTH + 10; ?>" valign="top" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_new_array[$i]['id']) . '">' . tep_image(DIR_WS_IMAGES . $products_new_array[$i]['image'], $products_new_array[$i]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>'; ?></td>

<td valign="top" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_new_array[$i]['id']) . '"><b><u>' . $products_new_array[$i]['name'] . '</u></b></a><br>' . TEXT_DATE_ADDED . ' ' . $products_new_array[$i]['date_added'] . '<br>' . TEXT_MANUFACTURER . ' ' . $products_new_array[$i]['manufacturer'] . '<br><br>' . TEXT_PRICE . ' ' . $products_price; ?></td>

<td align="right" valign="middle" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_NEW, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $products_new_array[$i]['id']) . '">' . tep_image_button('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</a>'; ?></td>

</tr>

<?php

if (($i+1) != $n) {

?>

<tr>

<td colspan="3" class="main"> </td>

</tr>

<?php

}

}

}

?>

</table>[/b]

 

and the following error occurs:

 

 

If I revert the changes, it works fine but without the separate pricing feature. Obviously. :lol:

 

Regards,

Christopher Dang

  • 2 weeks later...
Posted

try

<?php

/*

 $Id: products_new.php,v 1.11 2003/02/12 23:55:58 hpdl Exp $



 osCommerce, Open Source E-Commerce Solutions

 http://www.oscommerce.com



 Copyright (c) 2003 osCommerce



 Released under the GNU General Public License

*/

?>

<table border="0" width="100%" cellspacing="0" cellpadding="2">

<?php

 if (sizeof($products_new_array) < 1) {

?>

 <tr>

   <td class="main"><?php echo TEXT_NO_NEW_PRODUCTS; ?></td>

 </tr>

<?php

 } else {

   for($i=0, $n=sizeof($products_new_array); $i<$n; $i++) {

     if (isset($products_new_array[$i]['specials_price'])) {

       $products_price = '<s>' .  $currencies->display_price($products_new_array[$i]['price'], tep_get_tax_rate($products_new_array[$i]['tax_class_id'])) . '</s>  <span class="productSpecialPrice">' . $currencies->display_price($products_new_array[$i]['specials_price'], tep_get_tax_rate($products_new_array[$i]['tax_class_id'])) . '</span>';

     } else {

global $customer_id;

$customer_group_query = tep_db_query("select customers_group_id from " . TABLE_CUSTOMERS . " where customers_id =  '" . $customer_id . "'");

$customer_group = tep_db_fetch_array($customer_group_query);

$customer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . $products_new_array[$i]['id'] . "' and customers_group_id =  '" . $customer_group['customers_group_id'] . "'");

if ( $customer_group['customers_group_id'] != 0) {

  if ($customer_group_price = tep_db_fetch_array($customer_group_price_query)) {

    $products_price = $currencies->display_price($customer_group_price['customers_group_price'], tep_get_tax_rate($products_new_array[$i]['tax_class_id']));

    } else {

   $products_price = $currencies->display_price($products_new_array[$i]['price'], tep_get_tax_rate($products_new_array[$i]['tax_class_id'])

       }

} else {

     $products_price = $currencies->display_price($products_new_array[$i]['price'], tep_get_tax_rate($products_new_array[$i]['tax_class_id'])

 }

     }

?>

 <tr>

   <td width="<?php echo SMALL_IMAGE_WIDTH + 10; ?>" valign="top" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_new_array[$i]['id']) . '">' . tep_image(DIR_WS_IMAGES . $products_new_array[$i]['image'], $products_new_array[$i]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>'; ?></td>

   <td valign="top" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_new_array[$i]['id']) . '"><b><u>' . $products_new_array[$i]['name'] . '</u></b></a><br>' . TEXT_DATE_ADDED . ' ' . $products_new_array[$i]['date_added'] . '<br>' . TEXT_MANUFACTURER . ' ' . $products_new_array[$i]['manufacturer'] . '<br><br>' . TEXT_PRICE . ' ' . $products_price; ?></td>

   <td align="right" valign="middle" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_NEW, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $products_new_array[$i]['id']) . '">' . tep_image_button('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</a>'; ?></td>

 </tr>

<?php

     if (($i+1) != $n) {

?>

 <tr>

   <td colspan="3" class="main"> </td>

 </tr>

<?php

     }

   }

 }

?>

</table>

 

if you aint fixed it yet !!!

Regards Thorsten

Posted

ok...i think i might have fixed it...

 

try this:

 

In /var/www/html/catalog/includes/modules/products_new.php

 

Around line 26

 

FIND:

$whats_new_price =  $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id']));

 

 

REPLACE WITH:

	global $customer_id;

$customer_group_query = tep_db_query("select customers_group_id from " . TABLE_CUSTOMERS . " where customers_id =  '" . $customer_id . "'");

$customer_group = tep_db_fetch_array($customer_group_query);

$customer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . $random_product['products_id'] . "' and customers_group_id =  '" . $customer_group['customers_group_id'] . "'");

if ( $customer_group['customers_group_id'] != 0) {

  if ($customer_group_price = tep_db_fetch_array($customer_group_price_query)) {

    $whats_new_price = $currencies->display_price($customer_group_price['customers_group_price'], tep_get_tax_rate($random_product['products_tax_class_id']));

  } else {

     $products_price = $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id']));

    }



} else {



     $products_price = $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id']));

  }

Posted

Still has missing ;, try this one:

<?php

/*

 $Id: products_new.php,v 1.11 2003/02/12 23:55:58 hpdl Exp $



 osCommerce, Open Source E-Commerce Solutions

 http://www.oscommerce.com



 Copyright (c) 2003 osCommerce



 Released under the GNU General Public License

*/

?>

<table border="0" width="100%" cellspacing="0" cellpadding="2">

<?php

 if (sizeof($products_new_array) < 1) {

?>

 <tr>

   <td class="main"><?php echo TEXT_NO_NEW_PRODUCTS; ?></td>

 </tr>

<?php

 } else {

   for($i=0, $n=sizeof($products_new_array); $i<$n; $i++) {

     if (isset($products_new_array[$i]['specials_price'])) {

       $products_price = '<s>' .  $currencies->display_price($products_new_array[$i]['price'], tep_get_tax_rate($products_new_array[$i]['tax_class_id'])) . '</s>  <span class="productSpecialPrice">' . $currencies->display_price($products_new_array[$i]['specials_price'], tep_get_tax_rate($products_new_array[$i]['tax_class_id'])) . '</span>';

     } else {

global $customer_id;

$customer_group_query = tep_db_query("select customers_group_id from " . TABLE_CUSTOMERS . " where customers_id =  '" . $customer_id . "'");

$customer_group = tep_db_fetch_array($customer_group_query);

$customer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . $products_new_array[$i]['id'] . "' and customers_group_id =  '" . $customer_group['customers_group_id'] . "'");

if ( $customer_group['customers_group_id'] != 0) {

  if ($customer_group_price = tep_db_fetch_array($customer_group_price_query)) {

    $products_price = $currencies->display_price($customer_group_price['customers_group_price'], tep_get_tax_rate($products_new_array[$i]['tax_class_id']));

    } else {

   $products_price = $currencies->display_price($products_new_array[$i]['price'], tep_get_tax_rate($products_new_array[$i]['tax_class_id']);

       }

} else {

     $products_price = $currencies->display_price($products_new_array[$i]['price'], tep_get_tax_rate($products_new_array[$i]['tax_class_id']);

 }

     }

?>

 <tr>

   <td width="<?php echo SMALL_IMAGE_WIDTH + 10; ?>" valign="top" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_new_array[$i]['id']) . '">' . tep_image(DIR_WS_IMAGES . $products_new_array[$i]['image'], $products_new_array[$i]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>'; ?></td>

   <td valign="top" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_new_array[$i]['id']) . '"><b><u>' . $products_new_array[$i]['name'] . '</u></b></a><br>' . TEXT_DATE_ADDED . ' ' . $products_new_array[$i]['date_added'] . '<br>' . TEXT_MANUFACTURER . ' ' . $products_new_array[$i]['manufacturer'] . '<br><br>' . TEXT_PRICE . ' ' . $products_price; ?></td>

   <td align="right" valign="middle" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_NEW, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $products_new_array[$i]['id']) . '">' . tep_image_button('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</a>'; ?></td>

 </tr>

<?php

     if (($i+1) != $n) {

?>

 <tr>

   <td colspan="3" class="main"> </td>

 </tr>

<?php

     }

   }

 }

?>

</table>

When debugging, remember that each php statement needs to end with a ;. Two were missing from the previous code.

 

Hope this helps,

Matt

I love deadlines. I like the whooshing sound they make as they fly by. ---Douglas Adams

Posted

still got the same error with your code...

 

someone needs to rewrite this entire thing....

 

i mean, this contribution is awesome and would help a lot of people but the original one was ok, but not working as it should... or at least too many errors....

Posted

The error is here:

 

$products_price = $currencies->display_price($products_new_array[$i]['price'], tep_get_tax_rate($products_new_array[$i]['tax_class_id']) 

} 

} else { 

$products_price = $currencies->display_price($products_new_array[$i]['price'], tep_get_tax_rate($products_new_array[$i]['tax_class_id'])

 

Should be:

 

$products_price = $currencies->display_price($products_new_array[$i]['price'], tep_get_tax_rate($products_new_array[$i]['tax_class_id']); 

} 

} else { 

$products_price = $currencies->display_price($products_new_array[$i]['price'], tep_get_tax_rate($products_new_array[$i]['tax_class_id']); 

}

 

Note that I have added a semi-colon to each line :shock:

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...