Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[contribution] CGDiscountSpecials


hozone

Recommended Posts

CATALOG\INCLUDES\CLASSES\CURRENCIES.PHP

I replaced one referrence of "return PRICES_LOGGED_IN_TEXT" with "$products_price = $products_price + $products_price * abs($customer_discount) / 100;"

 

	//CGDiscountSpecials start
? ?function display_price($products_price, $products_tax, $quantity = 1) {
? ? ?global $customer_id;
? ? ?$query_price_to_guest = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " WHERE configuration_key = 'ALLOW_GUEST_TO_SEE_PRICES'");
? ? ?$query_price_to_guest_result = tep_db_fetch_array($query_price_to_guest); ? ? ?
? ? ?if (($query_price_to_guest_result['configuration_value']=='true') && !(tep_session_is_registered('customer_id'))) {
? $query_guest_discount = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " WHERE configuration_key = 'GUEST_DISCOUNT'");
? $query_guest_discount_result = tep_db_fetch_array($query_guest_discount);
? ? ? ? $customer_discount = $query_guest_discount_result['configuration_value'];
? ? ?if ($customer_discount >= 0) {
? ? ?$products_price = $products_price + $products_price * abs($customer_discount) / 100;
? ? ?} else {
? ? ?$products_price = $products_price - $products_price * abs($customer_discount) / 100;
? ? ?}
? ? ?return $this->format(tep_add_tax($products_price, $products_tax) * $quantity);
? } elseif (tep_session_is_registered('customer_id')) {
? ? ? ? $query = tep_db_query("select g.customers_groups_discount from " . TABLE_CUSTOMERS_GROUPS . " g inner join ?" . TABLE_CUSTOMERS ?. " c on g.customers_groups_id = c.customers_groups_id and c.customers_id = '" . $customer_id . "'");
? ? ? ? $query_result = tep_db_fetch_array($query);
? ? ? ? $customers_groups_discount = $query_result['customers_groups_discount'];
? ? ? ? $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'];
? ? ? ? $customer_discount = $customer_discount + $customers_groups_discount;
? ? ?if ($customer_discount >= 0) {
? ? ?$products_price = $products_price + $products_price * abs($customer_discount) / 100;
? ? ?} else {
? ? ?$products_price = $products_price - $products_price * abs($customer_discount) / 100;
? ? ?}
? ? ?return $this->format(tep_add_tax($products_price, $products_tax) * $quantity);
? ? ?} else {
? ? ? ? return PRICES_LOGGED_IN_TEXT;
? ? ?}
? ?}

function display_price_nodiscount($products_price, $products_tax, $quantity = 1) {
? ? ?global $customer_id;
? ? ?$query_price_to_guest = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " WHERE configuration_key = 'ALLOW_GUEST_TO_SEE_PRICES'");
? ? ?$query_price_to_guest_result = tep_db_fetch_array($query_price_to_guest); ? ? ?
? ? ?if (($query_price_to_guest_result['configuration_value']=='true') && !(tep_session_is_registered('customer_id'))) {
? return [color=red]$this->format(tep_add_tax($products_price, $products_tax) * $quantity);[/color]
? } elseif (tep_session_is_registered('customer_id')) {
? ? ? ? return $this->format(tep_add_tax($products_price, $products_tax) * $quantity);
? } else {
? return PRICES_LOGGED_IN_TEXT;
? }
? ?}
? ?//CGDiscountSpecials end

AXM, I think you replaced this "return PRICES_LOGGED_IN_TEXT" with "

$this->format(tep_add_tax($products_price, $products_tax) * $quantity);".

Link to comment
Share on other sites

  • Replies 126
  • Created
  • Last Reply

Top Posters In This Topic

CATALOG\SHOPPING_CART.PHP

All I changed in this code was to replace one "echo PRICES_LOGGED_IN_TEXT" with "$currencies->format($cart->showtotal());".

 

 ? ? ? ? ?//CGDiscountSpecials start
? ? ? ? ?global $customer_id;
? ? ? ? ?$query_price_to_guest = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " WHERE configuration_key = 'ALLOW_GUEST_TO_SEE_PRICES'");
? ? ? ? ?$query_price_to_guest_result = tep_db_fetch_array($query_price_to_guest);
? ? ? ? ?if (($query_price_to_guest_result['configuration_value']=='true') && !(tep_session_is_registered('customer_id'))) {
? ? ? ? ? ? echo $currencies->format($cart->show_total());
? ? ? ? ?} elseif (tep_session_is_registered('customer_id')) {
? ? ? ? ? ? echo $currencies->format($cart->show_total()); 
? ? ? ? ?} else {
? ? ? ? ? ? echo PRICES_LOGGED_IN_TEXT;
? ? ? ? ?}
? ? ? ? ?//CGDiscountSpecials end

 

 

CATALOG\INCLUDES\BOXES\SHOPPING_CART.PHP

Once again all I changed in this code was to replace one "echo PRICES_LOGGED_IN_TEXT" with "$currencies->format($cart->showtotal());".

 

 ?//CGDiscountSpecials start
?global $customer_id;
?$query_price_to_guest = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " WHERE configuration_key = 'ALLOW_GUEST_TO_SEE_PRICES'");
?$query_price_to_guest_result = tep_db_fetch_array($query_price_to_guest);
?if (($query_price_to_guest_result['configuration_value']=='true') && !(tep_session_is_registered('customer_id'))) {
? ? ?$box_text = $currencies->format($cart->show_total());
?} elseif (tep_session_is_registered('customer_id')) {
? ? ?$box_text = $currencies->format($cart->show_total());
?} else {
? ? ?$box_text = PRICES_LOGGED_IN_TEXT;
?}
?if ($cart->count_contents() > 0) {
? ?$info_box_contents[] = array('text' => tep_draw_separator());
? ?$info_box_contents[] = array('align' => 'right',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'text' => $box_text);
?}
?//CGDiscountSpecials end

AXM,

 

It's ($cart->show_total());....u missed out the underscore and when I installed, it broke the code.

 

But overall, thanks for sharing the fix. Let's wait for it to be coded into the next release.

Edited by chaicka
Link to comment
Share on other sites

Bugs/To-Fix in v1.4b

 

1. When a customer is in a group discount, and a particular item is on special offer, CGDiscount will not take the lower price.

 

Eg. Item A is $12 at normal price, but with group discount of 10% is $10.80, but because it's on special offer at $11 for the month, the CGDiscountSpecial mod will take the price to be $11, instead of taking the lower price of the two prices.

Link to comment
Share on other sites

Hi. After installing this great contribution, I'm getting a small error on my shopping cart which i've circled in red in the image below. Can anyone point me in the right direction as to why this is showing up?

 

error.gif

Link to comment
Share on other sites

Hi. After installing this great contribution, I'm getting a small error on my shopping cart which i've circled in red in the image below. Can anyone point me in the right direction as to why this is showing up?

 

error.gif

Must likely you mis-placed some codes in that .php.....go thru the codes again.

Link to comment
Share on other sites

Just in case someone else run's into this, here's my solution. I don't think this is the right solution, but it's the only one that made the error go away.

 

/catalog/shopping_cart.php

<?php     
         //CGDiscountSpecials start
        global $customer_id;
        $query_price_to_guest = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " WHERE configuration_key = 'ALLOW_GUEST_TO_SEE_PRICES'");
        $query_price_to_guest_result = tep_db_fetch_array($query_price_to_guest);
        if (($query_price_to_guest_result['configuration_value']=='true') && !(tep_session_is_registered('customer_id'))) {
           //echo $currencies->format($cart->show_total());
        } elseif (tep_session_is_registered('customer_id')) {
           //echo $currencies->format($cart->show_total());
        } else {
           //echo PRICES_LOGGED_IN_TEXT;
        }
        //CGDiscountSpecials end
?>

Link to comment
Share on other sites

Okay I was able to fix all the "Must Be Logged In To See Prices".

 

Hozone I'm going to post the files up here and go ahead and take the liberty and putting them in your next update if you want.

 

Look for the following sections and make the appropriate changes.

 

 

CATALOG\SHOPPING_CART.PHP

All I changed in this code was to replace one "echo PRICES_LOGGED_IN_TEXT" with "$currencies->format($cart->showtotal());.

 

 ? ? ? ? ?//CGDiscountSpecials start
? ? ? ? ?global $customer_id;
? ? ? ? ?$query_price_to_guest = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " WHERE configuration_key = 'ALLOW_GUEST_TO_SEE_PRICES'");
? ? ? ? ?$query_price_to_guest_result = tep_db_fetch_array($query_price_to_guest);
? ? ? ? ?if (($query_price_to_guest_result['configuration_value']=='true') && !(tep_session_is_registered('customer_id'))) {
? ? ? ? ? ? echo $currencies->format($cart->show_total());
? ? ? ? ?} elseif (tep_session_is_registered('customer_id')) {
? ? ? ? ? ? echo $currencies->format($cart->show_total()); 
? ? ? ? ?} else {
? ? ? ? ? ? echo PRICES_LOGGED_IN_TEXT;
? ? ? ? ?}
? ? ? ? ?//CGDiscountSpecials end

 

 

CATALOG\INCLUDES\BOXES\SHOPPING_CART.PHP

Once again all I changed in this code was to replace one "echo PRICES_LOGGED_IN_TEXT" with "$currencies->format($cart->showtotal());.

 

 ?//CGDiscountSpecials start
?global $customer_id;
?$query_price_to_guest = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " WHERE configuration_key = 'ALLOW_GUEST_TO_SEE_PRICES'");
?$query_price_to_guest_result = tep_db_fetch_array($query_price_to_guest);
?if (($query_price_to_guest_result['configuration_value']=='true') && !(tep_session_is_registered('customer_id'))) {
? ? ?$box_text = $currencies->format($cart->show_total());
?} elseif (tep_session_is_registered('customer_id')) {
? ? ?$box_text = $currencies->format($cart->show_total());
?} else {
? ? ?$box_text = PRICES_LOGGED_IN_TEXT;
?}
?if ($cart->count_contents() > 0) {
? ?$info_box_contents[] = array('text' => tep_draw_separator());
? ?$info_box_contents[] = array('align' => 'right',
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'text' => $box_text);
?}
?//CGDiscountSpecials end

 

 

CATALOG\INCLUDES\CLASSES\CURRENCIES.PHP

I replaced one referrence of "return PRICES_LOGGED_IN_TEXT" with "$products_price = $products_price + $products_price * abs($customer_discount) / 100;"

 

	//CGDiscountSpecials start
? ?function display_price($products_price, $products_tax, $quantity = 1) {
? ? ?global $customer_id;
? ? ?$query_price_to_guest = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " WHERE configuration_key = 'ALLOW_GUEST_TO_SEE_PRICES'");
? ? ?$query_price_to_guest_result = tep_db_fetch_array($query_price_to_guest); ? ? ?
? ? ?if (($query_price_to_guest_result['configuration_value']=='true') && !(tep_session_is_registered('customer_id'))) {
? $query_guest_discount = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " WHERE configuration_key = 'GUEST_DISCOUNT'");
? $query_guest_discount_result = tep_db_fetch_array($query_guest_discount);
? ? ? ? $customer_discount = $query_guest_discount_result['configuration_value'];
? ? ?if ($customer_discount >= 0) {
? ? ?$products_price = $products_price + $products_price * abs($customer_discount) / 100;
? ? ?} else {
? ? ?$products_price = $products_price - $products_price * abs($customer_discount) / 100;
? ? ?}
? ? ?return $this->format(tep_add_tax($products_price, $products_tax) * $quantity);
? } elseif (tep_session_is_registered('customer_id')) {
? ? ? ? $query = tep_db_query("select g.customers_groups_discount from " . TABLE_CUSTOMERS_GROUPS . " g inner join ?" . TABLE_CUSTOMERS ?. " c on g.customers_groups_id = c.customers_groups_id and c.customers_id = '" . $customer_id . "'");
? ? ? ? $query_result = tep_db_fetch_array($query);
? ? ? ? $customers_groups_discount = $query_result['customers_groups_discount'];
? ? ? ? $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'];
? ? ? ? $customer_discount = $customer_discount + $customers_groups_discount;
? ? ?if ($customer_discount >= 0) {
? ? ?$products_price = $products_price + $products_price * abs($customer_discount) / 100;
? ? ?} else {
? ? ?$products_price = $products_price - $products_price * abs($customer_discount) / 100;
? ? ?}
? ? ?return $this->format(tep_add_tax($products_price, $products_tax) * $quantity);
? ? ?} else {
? ? ? ? return PRICES_LOGGED_IN_TEXT;
? ? ?}
? ?}

function display_price_nodiscount($products_price, $products_tax, $quantity = 1) {
? ? ?global $customer_id;
? ? ?$query_price_to_guest = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " WHERE configuration_key = 'ALLOW_GUEST_TO_SEE_PRICES'");
? ? ?$query_price_to_guest_result = tep_db_fetch_array($query_price_to_guest); ? ? ?
? ? ?if (($query_price_to_guest_result['configuration_value']=='true') && !(tep_session_is_registered('customer_id'))) {
? return $this->format(tep_add_tax($products_price, $products_tax) * $quantity);
? } elseif (tep_session_is_registered('customer_id')) {
? ? ? ? return $this->format(tep_add_tax($products_price, $products_tax) * $quantity);
? } else {
? return PRICES_LOGGED_IN_TEXT;
? }
? ?}
? ?//CGDiscountSpecials end

Good day Sir,

I applies the fix as you suggested and it works fab!!! Excelt I still have one instance of Must be logged in to see prices ... it is after the product is put into the cart in the middle section of the Product_info.php page..... can you assist me what to alter to make it show the price? Thank you so much

Link to comment
Share on other sites

I have just installed the latest version (1.41b) but i have a problem.

When in the Admin i wanted to gif a user a special discount i don't see these options on the screen..

The only thing i see is the normal entries but nothing where i can select the discount.

Am i doing something wrong???

 

Henk

Greetings,

 

Henk Bartels

Link to comment
Share on other sites

Well, I've started writing a step by step instruction sheet...

... and then I gave up on it - sorry folks.

 

There's simply too many changes that have to be done. I did them all manually. It took me about 3 hours, but I got it running the 1st time! :D YEEHAAW! :D There was just one small error in the shopping cart, but I was able to fix it quickly.

 

I've seen mentions of a "merge" utility - any info on that would be appreciated!

 

Thanks go out to all that made this contribution what it is - A great addition to OSC!

 

PS

 

Is there any way to show original and the discounted price to those in the discount group? :rolleyes:

John Skurka

Link to comment
Share on other sites

Firstly, thanks for a wonderful contribution. Despite being a newbie I was able to get it up and running quickly.

 

A question: After having got this all working beautifully, my customer now tells me he wants both the non-discounted AND the discounted prices showing :angry: , so that his customers can see what their savings are throughout (it is a B2B site).

 

Anyone done this or have any suggestions? - full prices with cross-outs through them and the prices with the customer discount applied underneath...

 

THANKS for any help! :rolleyes:

Link to comment
Share on other sites

Link to comment
Share on other sites

  • 1 month later...

First of all I just installed your CG discount contributions. It looks great, well I could able to succeed at showing prices to the guests.

But for specials also I need to show some discount prices to guest..

Is it possible..

Please suggest..

thanks

ss

Link to comment
Share on other sites

Hi! Does anyone know if the prices with a discount are sent in an order confirmation letter to a customer? With me it's not working - customers can see default prices in these e-mails. Prices in ADMIN>ORDERS are also without discounts. Help, please, this is urgent cause I have already installed this contrib on a live shop and customers keep receiving prices without discounts. :(

Link to comment
Share on other sites

First of all I just installed your CG discount contributions. It looks great, well I could able to succeed at showing prices to the guests.

But for specials also I need to show some discount prices to guest..

Is it possible..

Please suggest..

thanks

ss

only some?

 

in totalB2B you will have a option from admin:

"show prices to guest" (Show all prices to guest or don't show)

osCommerce Italia support: http://www.oscommerceitalia.com

Link to comment
Share on other sites

Hi! Does anyone know if the prices with a discount are sent in an order confirmation letter to a customer? With me it's not working - customers can see default prices in these e-mails. Prices in ADMIN>ORDERS are also without discounts. Help, please, this is urgent cause I have already installed this contrib on a live shop and customers keep receiving prices without discounts. :(

in totalB2B order confirmation mail are sent with discounted prices. also admin/orders's prices are with discount applied

osCommerce Italia support: http://www.oscommerceitalia.com

Link to comment
Share on other sites

QUOTE (tradertt @ Jan 23 2004, 02:40 PM)

Hi

 

I have tried to install this mod and got a problem .. when I set a 20% discount this is what happens.

 

Item selling normal price: $50

 

After 20% discount - $40.00

 

However, in the TOTAL it states $32 (which seems like it too another 20% off the $40.

 

In the SUB TOTAL however, it states the correct $40.00

 

Help please anyone

 

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

 

I have this problem also -> can't find a fix for this problem

 

On the order total page and the order confirm E-mail the Prises for the single Products are false (once again 20% Discount)

 

 

That's one confirm E-Mail to the customers...

 

 

Artikel

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

1 x 1-Kanal Handsender 40,685 MHz AM mit Codierleiste (FH-DI1.40A-1) = 21.20EUR

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

Zwischensumme: 26.50EUR

Versandkosten nach Gewicht (): 5.00EUR

Summe: 31.50EUR

 

Please help me!

 

I use the Version 1.4bfix plus German

Link to comment
Share on other sites

Has anyone used this with the Price Break contribution? Not only do I want to give a discount for quantity buying but I also want to give a further discount to groups. However the Price Break change in product info

has altered the pricing statement from this:

 

if ($new_price = tep_get_products_special_price($product_info['products_id'])) {

$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($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>';

} else {

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

}

 

to

$pf->loadProduct((int)$HTTP_GET_VARS['products_id'], (int)$languages_id);

$products_price=$pf->getPriceString();

 

Group Discount wants to alter the original to:

 

//GroupDiscount start

$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>';

//GroupDiscount end

With the bold above being the change. However the Price breal module removes the above statement.

Any ideas on where I can put the discount pricing?

Thanks

Link to comment
Share on other sites

  • 1 year later...

Hello all,

 

i have installed this great contrib, and all works great solong.

But when i put a thing into the shopping cart, and i need to checkout i see this :(

 

Fatal error: Call to undefined function: tep_get_configuration_key_value() in /home/httpd/vhosts/creativ4you.com/httpdocs/shop/includes/classes/shipping.php on line 35

 

I have merged all files with winmerge,and i dunno who the problem is.

 

I have installed CGDiscount 1.41b and Download Controller what code makes the error,

after installing CG Discount.

 

Can anybody help please ?

 

Regards

Hobbes

Link to comment
Share on other sites

  • 3 months later...

Sounds like you got out lucky. I applied the mod with winmerge(background in php = nil) and now I dont have anything in my shopping cart. When will I learn to back things up? I have MVS on my site and the person who wrote that script has worked with me in getting that mod up as well as a few others. I pay him pretty well for it but, I don't know if I want to bother him with this script. Does anyone know why the mod will work a few times and then all of a sudden nothing populates in the shopping cart?

 

Jeff :blink:

 

 

Hello all,

 

i have installed this great contrib, and all works great solong.

But when i put a thing into the shopping cart, and i need to checkout i see this :(

 

Fatal error: Call to undefined function: tep_get_configuration_key_value() in /home/httpd/vhosts/creativ4you.com/httpdocs/shop/includes/classes/shipping.php on line 35

 

I have merged all files with winmerge,and i dunno who the problem is.

 

I have installed CGDiscount 1.41b and Download Controller what code makes the error,

after installing CG Discount.

 

Can anybody help please ?

 

Regards

Hobbes

Link to comment
Share on other sites

  • 3 months later...
  • 2 months later...

This is a wonderful contribution! Exacrtly what I'm looking for! My only problem is that I'm totally dumb to these, and I was working hard to setup a working shop, so I'm not brave enought to experiment and break the shop, also I don't really understand the install instructuions :(

 

I would be really thankful if someone could make this conrib working properly in my shop!

 

....anyone? Pleeeeaaassee ? :)

Link to comment
Share on other sites

Well, your on the right track. Asking for help is the first thing I did. Following the directions is the second bit of help I needed. The thing that really helped me the most was setting up a duplicate shop on a dummy server. If your code is good for your original shop, just copy and paste all the files into another directory (separate from your shop directory entirely) and make changes to that site first. That way you dont have to worry about breaking the shop. If it breaks, it's not the original shop and your webstore is safe. Another thing you can do is to keep a backup copy of all the files somewhere on a zip/cd/dvd. This way if you mess up one of the files on accident, you can restore just that one file. There's lots of people here that can help you and as you've shown, your not afraid to ask.

 

Jefro

 

If you'd like to take a look at mine, they're at:

midnightofferings.com and retrodrivein.com

 

 

 

This is a wonderful contribution! Exacrtly what I'm looking for! My only problem is that I'm totally dumb to these, and I was working hard to setup a working shop, so I'm not brave enought to experiment and break the shop, also I don't really understand the install instructuions :(

 

I would be really thankful if someone could make this conrib working properly in my shop!

 

....anyone? Pleeeeaaassee ? :)

Link to comment
Share on other sites

My concern is that as I don't understand anything even not from the basic shop. Also I was trying to customize it with some contriobutions, and I have no idea what has been changed, I'm just happy it's working, but it was a pain in the ass without understanding what I'm doing :) As it's probably not the basic installation anymore, I'd really appreciate is someone would make it work :) I can donate some free products in return from the shop ;)

 

Greetigns, neu

http://store.carrierbuilders.net

Link to comment
Share on other sites

  • 8 months later...

Hello

 

I do Have the same Problem that i See Discounted Price Everywhere like on product listining, specials etc but when i add them into the shopping cart, i see the original price in the shopping cart.

 

e.g Group 1 Has 50% dicount

Product Price is 100 €

 

 

It shows everywhere automatically 50 € , its okey

 

When i add to shopping cart it shows 100 € instead of 50 €

 

 

HELP !!!!!!!!!!!

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...