Jump to content
Sign in to follow this  
hozone

[contribution] CustomerDiscount

Recommended Posts

Sounds good for those willing to proceed. I ask however, does it work for you? I had to disable specials because because though it does not discount the special price (though it does the regular price in the special box), when a customer goes to the category to view product, the item is now discounted. However, if a customer adds this to the shopping cart, it reverts back to the normal special price.

 

I'm having a problem similar to this. I realize this mod is discontinued, but I don't need the advanced features of B2B and would rather not mess with trying to uninstall this one, and installing a new one. I have a few customers that get a 100% discount-that's all I need it for.

 

The problem I'm having is that the prices display correctly throughout the catalog, but when you get to the cart it displays the normal price from then on.

I have a feeling it's a simple fix, I just don't know how to do it.

Can anyone help please?

Share this post


Link to post
Share on other sites

Meh.. this is pretty useless contribution...

 

Now my main page can't display...

 

Parse error: syntax error, unexpected T_VARIABLE, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/lowprice/public_html/includes/classes/shopping_cart.php on line 78

 

I just copy and paste... now it's jam... i don't know how to fix it...

Share this post


Link to post
Share on other sites
This contribution adds a Discount Rate per Customers, the administrator can

easily edit discounts from the administration Customers panel.

Every Customers has its own discount rate.

The prices in catalogue are already shown with the applied discount, unlike

other contributions like this that use the "order_total" method, to show a

final discount.

Discount rate is applied on every price, also on product attributes, but it is

not applied on special prices.

 

Download @ http://www.oscommerce.com/community/contributions,1672

 

 

I downloaded the contrib...however..will this work with earlier version of OSCommerce?

Share this post


Link to post
Share on other sites

Most of the contributions made available in this site are mainly for osCommerce v2.2..

 

However you can check the insturction after you downlaod the said contribution. If there's a mention that it works with previous version, that it should. Otherwise it only works with new version.

Share this post


Link to post
Share on other sites

Hello all,

I am getting an error when trying to implement this contribution. I did all the code mods by hand because I was afraid letting it work automatically would overwrite important info and render my shopping cart useless. My shopping cart is indeed NOT working, but only 'appears' to have one bug. When I go to my catalog page, it gives me this:

 

Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in d:\home\hnt27a040\catalog\includes\classes\shopping_cart.php on line 87

 

 

catalog\includes\classes\shopping_cart.php IS a file that gets modified in the installation instructions. I went back and compared my code additions to the install document and everything seemed to match. I also deleted and re-copied the code snippets into this .php file and the same error came back. I have NOT tried to copy the WHOLE shopping_cart.php from the contribution to my site for fear there may be other mods that have been made to this file by other modules that will then be rendered useless. Can anyone tell me what this means?? If I remove the following code from the shopping_cart.php file, and implement the original code that was there (I only commented it out, I did not delete it) my catalog and shopping cart then load correctly:

 

$products_id = tep_get_uprid($products_id, $attributes);

if ($notify == true) {

$new_products_id_in_cart = $products_id;

tep_session_register('new_products_id_in_cart');

}

 

if ($this->in_cart($products_id)) {

$this->update_quantity($products_id, $qty, $attributes);

} else {

$this->contents[] = array($products_id);

$this->contents[$products_id] = array('qty' => $qty);

// insert into database

if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')");

 

if (is_array($attributes)) {

reset($attributes);

while (list($option, $value) = each($attributes)) {

$this->contents[$products_id]['attributes'][$option] = $value;

// insert into database

if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "')");

}

}

}

$this->cleanup();

 

// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure

$this->cartID = $this->generate_cart_id();

}

 

(THIS IS THE CODE THAT IS SUPPOSED TO BE THE REPLACEMENT CODE)

 

ANY THOUGHTS ANYONE?!?!

Share this post


Link to post
Share on other sites

***catalog/includes/classes/shopping_cart.php *****************

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

---Look for line 78:

 

The code here is different than a default 2.2 shopping_cart.php

 

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

Replace with:

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

********************************************************************

 

 

Is there any simple working contribution for giving a customer precentage discount?

Edited by nudylady

Share this post


Link to post
Share on other sites

If you are using sub totals to be shown in catalog/shopping_cart.php and if your using advaced cartbox v2 contribution this mod will show the discounted price

 

This will show the appropriate SUB TOTALS in the shopping_cart.php and if your using the Advanced Cartbox Version 2 contribution

 

catalog/includes/classes/shopping_cart.php

 

Search for function calculate()

 

Add the following line just above : $products_price = $product['products_price']);

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

//CustomerDiscount start

global $customer_id;

$query = tep_db_query("select customers_discount from " . TABLE_CUSTOMERS . " where customers_id = '" . $customer_id . "'");

$query_result = tep_db_fetch_array($query);

$customer_discount = $query_result['customers_discount'];

if (strstr($customer_discount, "+") != null) {

$product['products_price'] = $product['products_price'] + $product['products_price'] * abs($customer_discount) / 100;

} else {

$product['products_price'] = $product['products_price'] - $product['products_price'] * abs($customer_discount) / 100;

}

//CustomerDiscount end

 

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

 

 

The following changes will show the proper discounted price in the Advanced Cartbox Version 2. Contribution

 

Search for $products_form

 

Change $currencies->display_price($products[$i]['final_price']) TO

 

$currencies->display_price_nodiscount(($products[$i]['final_price'])


l8ter

Share this post


Link to post
Share on other sites

Hello ,

i have this error:

1054 - Unknown column 'g.customers_group_id' in 'field list'

 

select g.customers_group_id, g.customers_group_name from customers_groups g order by g.customers_group_id ASC limit 0, 20

 

[TEP STOP]

 

the .sql file has been put in data base.

I does not want to use TotalB2B too many problems with other contribs.

Edited by NEMROD34

Share this post


Link to post
Share on other sites

For Discount Groups Version 1.1

 

 

In admin/includes/database_tables:

define('TABLE_CUSTOMERS_GROUPS', 'customers_groups');

define('TABLE_GROUPS_INFOS', 'groups_info');

 

 

If you have :

Fatal error: Call to undefined function: tep_array_merge() in /homepages/18/d174112975/htdocs/demo/cestmoilepatron/admin/customers_groups.php on line 407

 

 

in admin customers-groups.php

 

change 'tep_array_merge' for 'array_merge'.

 

 

If this can help ...

 

But i dont see any customers in groups.

And i can't delete a catégorie with discount, i clic on delete but it's stay on here.

 

Sorry for my english i'm french ;-)

Edited by NEMROD34

Share this post


Link to post
Share on other sites

Hi.

 

I have a question.

 

Is there a way to disable discount prices for specials?

 

I don´t like the look of it, when it looks like the customer actualy gets the product more expensive than what they belive is the regular price (even if discounted).

 

If I could just remove the discount from products that is currently on a special offer....

 

Thanx

 

//Talle

Share this post


Link to post
Share on other sites

It would be necessary:

the normal price

You have a discount %

Price with discount

 

I am there but that is not even posted:

//CustomerDiscount start
  global $customer_id;
$query = tep_db_query("select customers_discount from " . TABLE_CUSTOMERS . " where customers_id = '" . $customer_id . "'");
$query_result = tep_db_fetch_array($query);
$customer_discount = $query_result['customers_discount'];
echo "<div align=center><font color=#ff0000><b>Vous bénéficiez d'une remise de  " . $customer_discount . "% </b></font></div>";
	   $products_price = '<s>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' .  $currencies->display_price_nodiscount($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>';
   //CustomerDiscount end

Edited by NEMROD34

Share this post


Link to post
Share on other sites

In shopping cart:

//CustomerDiscount start

$info_box_contents[$cur_row][] = array('align' => 'right',

'params' => 'class="productListing-data" valign="top"',

'text' => '<s>' . $currencies->display_price($products[$i]['products_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</s><br><span class="productSpecialPrice">' . $currencies->display_price_nodiscount($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</span>');

//CustomerDiscount end

 

But the real price is 0 !

Share this post


Link to post
Share on other sites

Another problem the sentence “You profit from such an amount of % handing-over” as well as double posting of the prices appears for a customer even visitors. It would be necessary that that left only if the customer is recognized with a percentage. I does not include/understand why.

//CustomerDiscount start
  $info_box_contents[$cur_row][] = array('align' => 'right',
										 'params' => 'class="productListing-data" valign="top"',
										 'text' => '<s>' . $currencies->display_price($product[$i]['products_price'], tep_get_tax_rate($product[$i]['products_tax_class_id'])) . '</s><br><span class="productSpecialPrice">' . $currencies->display_price_nodiscount($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</span>');
  //CustomerDiscount end

 

 

Autre problème la phrase "Vous bénéficiez de tant de % de remise" ainsi que le double affichage des prix apparait pour un client même visiteurs.

Il faudrait que ça ne sorte que si le client est reconnus avec un pourcentage.

Je ne comprend pas pourquoi.

<!-- body_text //-->

<td width="100%" valign="top"><?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_SHOPPING_CART, 'action=update_product')); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">

<tr>

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

<tr>

<td class="pageHeading"><?php echo HEADING_TITLE; ?> <br><b><font size="2" color="#FF0000"><?

global $customer_id;

$query = tep_db_query("select customers_discount from " . TABLE_CUSTOMERS . " where customers_id = '" . $customer_id . "'");

$query_result = tep_db_fetch_array($query);

$customer_discount = $query_result['customers_discount'];

echo "Vous bénéficiez d'une remise de " . $customer_discount . "% ";

?></font></b><br></td>

<td class="pageHeading" align="right"></td>

</tr>

</table></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<?php

if ($cart->count_contents() > 0) {

?>

<tr>

<td>

<?php

$info_box_contents = array();

$info_box_contents[0][] = array('align' => 'center',

'params' => 'class="productListing-heading"',

'text' => TABLE_HEADING_REMOVE);

 

$info_box_contents[0][] = array('params' => 'class="productListing-heading"',

'text' => TABLE_HEADING_PRODUCTS);

 

$info_box_contents[0][] = array('align' => 'center',

'params' => 'class="productListing-heading"',

'text' => TABLE_HEADING_QUANTITY);

 

$info_box_contents[0][] = array('align' => 'right',

'params' => 'class="productListing-heading"',

'text' => TABLE_HEADING_TOTAL);

 

$any_out_of_stock = 0;

$products = $cart->get_products();

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

// Push all attributes information in an array

if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {

while (list($option, $value) = each($products[$i]['attributes'])) {

echo tep_draw_hidden_field('id[' . $products[$i]['id'] . '][' . $option . ']', $value);

//++++ QT Pro: Begin Changed code

$attributes = tep_db_query("select popt.products_options_name, popt.products_options_track_stock, poval.products_options_values_name, pa.options_values_price, pa.price_prefix

from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa

where pa.products_id = '" . $products[$i]['id'] . "'

and pa.options_id = '" . $option . "'

and pa.options_id = popt.products_options_id

and pa.options_values_id = '" . $value . "'

and pa.options_values_id = poval.products_options_values_id

and popt.language_id = '" . $languages_id . "'

and poval.language_id = '" . $languages_id . "'");

//++++ QT Pro: End Changed Code

$attributes_values = tep_db_fetch_array($attributes);

 

$products[$i][$option]['products_options_name'] = $attributes_values['products_options_name'];

$products[$i][$option]['options_values_id'] = $value;

$products[$i][$option]['products_options_values_name'] = $attributes_values['products_options_values_name'];

$products[$i][$option]['options_values_price'] = $attributes_values['options_values_price'];

$products[$i][$option]['price_prefix'] = $attributes_values['price_prefix'];

//++++ QT Pro: Begin Changed code

$products[$i][$option]['track_stock'] = $attributes_values['products_options_track_stock'];

//++++ QT Pro: End Changed Code

}

}

}

 

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

if (($i/2) == floor($i/2)) {

$info_box_contents[] = array('params' => 'class="productListing-even"');

} else {

$info_box_contents[] = array('params' => 'class="productListing-odd"');

}

 

$cur_row = sizeof($info_box_contents) - 1;

 

 

 

 

 

$info_box_contents[$cur_row][] = array('align' => 'center',

'params' => 'class="productListing-data" valign="top"',

'text' => tep_draw_checkbox_field('cart_delete[]', $products[$i]['id'], ' ', 'onClick="DoSubmission();"'));

 

$products_name = '<table border="0" cellspacing="2" cellpadding="2">' .

' <tr>' .

' <td class="productListing-data" align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">' . tep_image(DIR_WS_IMAGES . $products[$i]['image'], $products[$i]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>' .

' <td class="productListing-data" valign="top"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '"><b>' . $products[$i]['name'] . '</b></a>';

 

if (STOCK_CHECK == 'true') {

//++++ QT Pro: Begin Changed code

if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {

$stock_check = tep_check_stock($products[$i]['id'], $products[$i]['quantity'], $products[$i]['attributes']);

}else{

$stock_check = tep_check_stock($products[$i]['id'], $products[$i]['quantity']);

}

//++++ QT Pro: End Changed Code

if (tep_not_null($stock_check)) {

$any_out_of_stock = 1;

 

$products_name .= $stock_check;

}

}

 

if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {

reset($products[$i]['attributes']);

while (list($option, $value) = each($products[$i]['attributes'])) {

$products_name .= '<br><small><i> - ' . $products[$i][$option]['products_options_name'] . ' ' . $products[$i][$option]['products_options_values_name'] . '</i></small>';

}

}

 

$products_name .= ' </td>' .

' </tr>' .

'</table>';

 

$info_box_contents[$cur_row][] = array('params' => 'class="productListing-data"',

'text' => $products_name);

// javascript jaen luc

?>

<script language="javascript">

function majQuantity(qty,i)

{

quantity = document.cart_quantity['cart_quantity['+i+']'].value;

quantity = parseInt(quantity) + parseInt(qty)

if (quantity < 1)

{

quantity = 1;

}

document.cart_quantity['cart_quantity['+i+']'].value = quantity;

}

 

</script>

<?php

$info_box_contents[$cur_row][] = array('align' => 'center',

'params' => 'class="productListing-data" valign="top"',

'text' =>

/*tep_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4"') . tep_draw_hidden_field('products_id[]', $products[$i]['id']));

+- shopping cart par jean luc post 19815 */

'

<table border="0" cellspacing="0">

<tr>

<td valign="middle" class="qte">

<div align="center">'. tep_draw_input_field('cart_quantity['.$i.']', $products[$i]['quantity'], 'size="4"') . tep_draw_hidden_field('products_id[]', $products[$i]['id']).'

</div>

</td>

<td class="qte" >

<div align="center"><div><div onClick="majQuantity(1,'.$i.'); document.forms.cart_quantity.submit()">'.tep_image(DIR_WS_IMAGES.'plus.gif', IMAGE_BUTTON_PLUS).'</div>

<div onClick="majQuantity(-1,'.$i.'); document.forms.cart_quantity.submit()">'.tep_image(DIR_WS_IMAGES.'moins.gif', IMAGE_BUTTON_MOINS).'</div></div>

</td>

 

<td align="center"> </td>

</td>

</tr>

 

</table>

' );

//CustomerDiscount start

$info_box_contents[$cur_row][] = array('align' => 'right',

'params' => 'class="productListing-data" valign="top"',

'text' => '<s>' . $currencies->display_price($products[$i]['products_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</s><br><span class="productSpecialPrice">' . $currencies->display_price_nodiscount($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</span>');

//CustomerDiscount end

}

 

new productListingBox($info_box_contents);

?>

Share this post


Link to post
Share on other sites

hello

here it is necessary me to apply the reduction to the product and not to the options. MOREOVER it is necessary that that left only in the basket: I did that:

dans currencies.php

in bottom pagepage :

//CustomerDiscount start
function display_price_nodiscount($products_price, $products_tax, $quantity = 1) {
  global $customer_id;
  $query = tep_db_query("select customers_discount from " . TABLE_CUSTOMERS . " where customers_id =  '" . $customer_id . "'");
  $query_result = tep_db_fetch_array($query);
  $customer_discount = $query_result['customers_discount'];
  if (strstr($customer_discount, "+") != null) {
	  $products_price_nodiscount = $products_price + $products_price * abs($customer_discount) / 100;
  } else {
	  $products_price_nodiscount = $products_price - $products_price * abs($customer_discount) / 100;
  }
  return $this->format(tep_add_tax($products_price, $products_tax) * $quantity);
}

function display_price($products_price, $products_tax, $quantity = 1) {
  return $this->format(tep_add_tax($products_price, $products_tax) * $quantity);
}
//CustomerDiscount end


 }
?>

 

 

replace:

 

'params' => 'class="productListing-data" valign="top"',
										 'text' => '<b>' . $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</b>');

 

by:

//CustomerDiscount end
'params' => 'class="productListing-data" valign="top"',
'text' =>   '<b>' . $currencies->display_price_nodiscount($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</b>');
  //CustomerDiscount end

 

i delete:

//CustomerDiscount start
	  global $customer_id;
	  $query = tep_db_query("select customers_discount from " . TABLE_CUSTOMERS . " where customers_id =  '" . $customer_id . "'");
	  $query_result = tep_db_fetch_array($query);
	  $customer_discount = $query_result['customers_discount'];
	  if (strstr($customer_discount, "+") != null) {
		 $attribute_price['options_values_price'] = $attribute_price['options_values_price'] + $attribute_price['options_values_price'] * abs($customer_discount) / 100;
	  } else {
		 $attribute_price['options_values_price'] = $attribute_price['options_values_price'] - $attribute_price['options_values_price'] * abs($customer_discount) / 100;
//CustomerDiscount end

 

 

 

Here I have the price of work + the framed price of the option.

 

In under total I have price of work-20% + price of option it's ok

snap1qo6.jpg

 

ut in checkout_confirmation I have not the reduction in the subtotal:

snap2ph1.jpg

 

 

i want the same subtotal like shopping_cart in checkout_confimation.

Share this post


Link to post
Share on other sites

Hi.

 

I've been asked to get this discount thing working and I am not the best codehead in the world!

 

I replaced the files with those in the folder named MS2 patched files, but it doesn't appear to work, when you click on check out you just get a blank page.

 

Can anyone give me a hand with this or a clue as to what I may have done wrong?

 

many thanks.

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  

×