Jump to content
Sign in to follow this  
hozone

[contribution] CGDiscountSpecials

Recommended Posts

Right found another little problem with specials I think.

 

First I have 2 groups 1 is default and 2 is whiolesale.

 

Specials discount = 10%

 

When I set myself as wholesale with 20% discount the specials work fine adding a specials % ontop of the wholesale % resulting in a 30% wholesale discount on that product ok.

 

However, if you set special discount to a group like default, should this special only show for default users and not offer wholesale a special at all?

 

Pics here

 

snapshot2.gif

snapshot3.gif

 

Hope this helps you.

 

Regards

Elwyn

Edited by j0ker

Always seeking & Desperate to find a solution!

Share this post


Link to post
Share on other sites
Another possible bug?

 

Right I have seen this a number of times before, but now the worst problem I had is sorted what would you say was the solution to this issue I have I have included a snap shot of the problem but when you dont log in and still add to cart when you get as far as cart it displays price of item.snapshot1.gif

 

Thx in advance

 

Also It is a basic install of osc2.2ms2 and sts1.8 and your contribute nothing else

 

Regards

Elwyn

bug fixed:

 

use this files for:

catalog/includes/boxes/shopping_cart.php

<?php
/*
 $Id: shopping_cart.php,v 1.18 2003/02/10 22:31:06 hpdl Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/
?>
<!-- shopping_cart //-->
         <tr>
           <td>
<?php
 $info_box_contents = array();
 $info_box_contents[] = array('text' => BOX_HEADING_SHOPPING_CART);

 new infoBoxHeading($info_box_contents, false, true, tep_href_link(FILENAME_SHOPPING_CART));

 $cart_contents_string = '';
 if ($cart->count_contents() > 0) {
   $cart_contents_string = '<table border="0" width="100%" cellspacing="0" cellpadding="0">';
   $products = $cart->get_products();
   for ($i=0, $n=sizeof($products); $i<$n; $i++) {
     $cart_contents_string .= '<tr><td align="right" valign="top" class="infoBoxContents">';

     if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {
       $cart_contents_string .= '<span class="newItemInCart">';
     } else {
       $cart_contents_string .= '<span class="infoBoxContents">';
     }

     $cart_contents_string .= $products[$i]['quantity'] . ' x </span></td><td valign="top" class="infoBoxContents"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">';

     if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {
       $cart_contents_string .= '<span class="newItemInCart">';
     } else {
       $cart_contents_string .= '<span class="infoBoxContents">';
     }

     $cart_contents_string .= $products[$i]['name'] . '</span></a></td></tr>';

     if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {
       tep_session_unregister('new_products_id_in_cart');
     }
   }
   $cart_contents_string .= '</table>';
 } else {
   $cart_contents_string .= BOX_SHOPPING_CART_EMPTY;
 }

 $info_box_contents = array();
 $info_box_contents[] = array('text' => $cart_contents_string);

 //CGDiscountSpecials start
 global $customer_id;
 if (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

 new infoBox($info_box_contents);
?>
           </td>
         </tr>
<!-- shopping_cart_eof //-->

 

catalog/shopping_cart.php (replace this above at line 160)

      <tr>
       <td align="right" class="main"><b><?php echo SUB_TITLE_SUB_TOTAL; ?> <?php 
    
         //CGDiscountSpecials start
         global $customer_id;
         if (tep_session_is_registered('customer_id')) {
            echo $currencies->format($cart->show_total()); 
         } else {
            echo PRICES_LOGGED_IN_TEXT;
         }
         //CGDiscountSpecials end

 ?></b></td>
     </tr>

 

 

 

tell me if it works even for you.


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

Share this post


Link to post
Share on other sites
Right found another little problem with specials I think.

 

First I have 2 groups 1 is default and 2 is whiolesale.

 

Specials discount = 10%

 

When I set myself as wholesale with 20% discount the specials work fine adding a specials % ontop of the wholesale % resulting in a 30% wholesale discount on that product ok.

 

However, if you set special discount to a group like default, should this special only show for default users and not offer wholesale a special at all?

 

Pics here

 

snapshot2.gif

snapshot3.gif

 

Hope this helps you.

 

Regards

Elwyn

i think it is right.

 

if you want a special price to be for ALL just don't select any group or customer.

 

if you select group "default" the special price should be for only users in group default.

customers in group "wholesale" will see special prices only for "wholesale" group.


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

Share this post


Link to post
Share on other sites
Hi Davide

 

1st I think it is a great contrib, but I will also need to specify product categories discounts for customers groups.

 

But first I have some trouble getting the contrib working. It installs well -> when you a brose a category of say 100 products, It shows only the first page and linsk to go to other pages to see more products is missing.

 

What am I doing wrong.?

 

Thanks

 

SSD

this is because you are using version 1.2

i have a 1.3PRE that fix this bug, but i cant find NO-ONE (in 1 month!!) that test this contribution. i'm using this (1.3pre), and it seems to work, but i wont someone to test it better.

if you want i can mail this contrib to you (sen me a mail)

if you test it i'll post the 1.3 to this comunity, before your test!.

Davide

 

Thx for the update. I can be yor tester for 1.3PRE. Give me the url to download it when you are ready

 

SSD ;)

Davide,

 

I think you have done a fine job with 1.3. and have solved the issue, except in specials. I have 21 specials, and once logged-in it's not possible to go to the next pages - the bar / links are missing.

 

Simles,

 

SSD

Share this post


Link to post
Share on other sites

Hi people

 

I'm a php newbie and I have a question.

 

I have 100 customers and I'd like to give 10 people a special price. I'm only able to give 1 person from 100 people a special price so the question is if it's possible to change the special.php so I can give all 10 a special price instead of just one person?

 

greetings

kay

Share this post


Link to post
Share on other sites
Hi Davide

 

1st I think it is a great contrib, but I will also need to specify product categories discounts for customers groups.

 

But first I have some trouble getting the contrib working. It installs well -> when you a brose a category of say 100 products, It shows only the first page and linsk to go to other pages to see more products is missing.

 

What am I doing wrong.?

 

Thanks

 

SSD

this is because you are using version 1.2

i have a 1.3PRE that fix this bug, but i cant find NO-ONE (in 1 month!!) that test this contribution. i'm using this (1.3pre), and it seems to work, but i wont someone to test it better.

if you want i can mail this contrib to you (sen me a mail)

if you test it i'll post the 1.3 to this comunity, before your test!.

Davide

 

Thx for the update. I can be yor tester for 1.3PRE. Give me the url to download it when you are ready

 

SSD ;)

Davide,

 

I think you have done a fine job with 1.3. and have solved the issue, except in specials. I have 21 specials, and once logged-in it's not possible to go to the next pages - the bar / links are missing.

 

Simles,

 

SSD

i know this bug.. but actually i'm not able to solve it because of mysql. to solve this bug i need sub-query, available from version 4.1 of mysql. most of the people use mysql 4.0x


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

Share this post


Link to post
Share on other sites

version 1.3c is out

 

v1.3c - by hOZONE

----

. fixed a bug in calculating prices in:

catalog/includes/modules/new_products.php

catalog/includes/boxes/shopping_cart.php

catalog/shopping_cart.php


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

Share this post


Link to post
Share on other sites
I was successful in getting the price to show correctly on: http://test.vmwake.com/checkout_confirmation.php, however, I had to change:

 

//CGDiscountSpecials start

echo ' <td class="main" align="right" valign="top">' . $currencies->display_price_nodiscount($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . '</td>' . "\n" .

' </tr>' . "\n";

//CGDiscountSpecials end

 

-to-

 

//CGDiscountSpecials start

echo ' <td class="main" align="right" valign="top">' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . '</td>' . "\n" .

' </tr>' . "\n";

//CGDiscountSpecials end

 

 

Can someone please help me find out how I can get the correct subtotals through checkout? I assume that the ?Order Totals? module needs to be changed.

Hi Matt,

 

I'm wondering if you ever figured this out. I'm using STS, along w/ SEC.

 

I don't see STS causing a problem since it wraps around the outside of things.

 

I used your "fix" and got the price to show right under the products in the prod. conf. page, but it's still showing up as the full price under billing (and goes through as full priced if you place the order).

 

Also, hoping it would provide a solution, I updated CGDiscountSpecials to the latest version & applied the latest patches. No luck.

 

Any ideas on what you've found out would be great.

 

Cheers!

 

Chris

Share this post


Link to post
Share on other sites
I was successful in getting the price to show correctly on: http://test.vmwake.com/checkout_confirmation.php, however, I had to change:

 

//CGDiscountSpecials start

? ? echo '? ? ? ? ? ? <td class="main" align="right" valign="top">' . $currencies->display_price_nodiscount($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . '</td>' . "\n" .

? ? ? ?  '? ? ? ? ? </tr>' . "\n";

? ? //CGDiscountSpecials end

 

-to-

 

//CGDiscountSpecials start

? ? echo '? ? ? ? ? ? <td class="main" align="right" valign="top">' . $currencies->display_price($order->products[$i]['final_price'], $order->products[$i]['tax'], $order->products[$i]['qty']) . '</td>' . "\n" .

? ? ? ?  '? ? ? ? ? </tr>' . "\n";

? ? //CGDiscountSpecials end

 

 

Can someone please help me find out how I can get the correct subtotals through checkout? I assume that the ?Order Totals? module needs to be changed.

Hi Matt,

 

I'm wondering if you ever figured this out. I'm using STS, along w/ SEC.

 

I don't see STS causing a problem since it wraps around the outside of things.

 

I used your "fix" and got the price to show right under the products in the prod. conf. page, but it's still showing up as the full price under billing (and goes through as full priced if you place the order).

 

Also, hoping it would provide a solution, I updated CGDiscountSpecials to the latest version & applied the latest patches. No luck.

 

Any ideas on what you've found out would be great.

 

Cheers!

 

Chris

Hi Davide,

 

I'm wondering/hoping if you're familiar enough with SEC & STS to help unravel this mystery.

 

You can see it in action at:

http://www.smallbusinessideas.com/index.php

(go through the biz guide products)

 

Cheers!

 

Chris

Edited by OregonBum

Share this post


Link to post
Share on other sites

Having the same problem as Updmike..

 

Special prices Override Customer discounts even when

 

 

customer discounts price > Specials discount price.

 

 

for example.. cust A has 50% discount on product resulting in it being $10

 

if I set specials on that product to $15, it will show $15.

 

anyone have a workaround?

 

TIA

Share this post


Link to post
Share on other sites

I posted the problem regarding the Must be logged in for prices! problem in the shopping cart in the discount thread. I saw that you posted v1.3e as a bug fix so I overwrote the files on my server (1.3e over 1.3d). After doing this, I got the "Must be logged in for prices!" message everywhere. So I put the following altered section in my /catalog/includes/classes/currencies.php. I did not change the database at all however.

 

//CGDiscountSpecials start modified to show prices when not logged in

  function display_price($products_price, $products_tax, $quantity = 1) {

    global $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);

  }

 

function display_price_nodiscount($products_price, $products_tax, $quantity = 1) {

    global $customer_id;

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

  }

  //CGDiscountSpecials end

 

This had the same affect as before, which was that prices showed up in every field except the shopping cart and the subtotal section when you are checking out after you have added a product to cart. Perhaps this is only affecting the subtotal field?

 

You can see the problem here (this is a test site and not finalized) https://host134.ipowerweb.com/~bmotorsp/catalog/

 

Problem when not logged in:

cgdiscount-problem.jpg

 

When logged in:

cgdiscount-problem_ok.jpg

Share this post


Link to post
Share on other sites

@PCS

 

the solution to your problem:

 

Also with this fix you can enable/disable show prices to guest from admin.

 

1.- You have to UNDO your /catalog/includes/classes/currencies.php to 1.3e version.

 

Then apply this:

 

update for CGDiscountSpecials 1.3d
by BigT

features :
- Enables admin to choose wether a default price should be accessible by guests.

description :
- true/false choice for "allow guest to see prices" property in admin >> configuration >> my store
- prices displayed will be computed from rules defined for group 'default'

support :
- it works fine for me but i don't give money back if it doesn't work for you :)
- still, if i have time, i might answer to emails sent to bigtiti@hotmail.com
- enjoy

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

in file catalog/includes/classes/currencies.php

replace

//CGDiscountSpecials start
   function display_price($products_price, $products_tax, $quantity = 1) {
     global $customer_id;
     if (tep_session_is_registered('customer_id')) {

by

   function display_price($products_price, $products_tax, $quantity = 1) {
     global $customer_id;
     $myQuery = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " WHERE configuration_key = 'ALLOW_GUEST_TO_SEE_PRICES'");
     $myQuery_result = tep_db_fetch_array($myQuery);      
     if ($myQuery_result['configuration_value']=='true' || tep_session_is_registered('customer_id')) {

and replace

   function display_price_nodiscount($products_price, $products_tax, $quantity = 1) {
     global $customer_id;
     if (tep_session_is_registered('customer_id')) {

by

   function display_price_nodiscount($products_price, $products_tax, $quantity = 1) {
     global $customer_id;
     $myQuery = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " WHERE configuration_key = 'ALLOW_GUEST_TO_SEE_PRICES'");
     $myQuery_result = tep_db_fetch_array($myQuery);
     if ($myQuery_result['configuration_value']=="true" || tep_session_is_registered('customer_id')) {

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

in file catalog/shopping_cart.php

replace

         //CGDiscountSpecials start
         global $customer_id;
         if (tep_session_is_registered('customer_id')) {

by

         //CGDiscountSpecials start
         global $customer_id;
         $myQuery = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " WHERE configuration_key = 'ALLOW_GUEST_TO_SEE_PRICES'");
         $myQuery_result = tep_db_fetch_array($myQuery);      
         if ($myQuery_result['configuration_value']=='true' || tep_session_is_registered('customer_id')) {

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

in file catalog/includes/boxes/shopping_cart.php

replace

 //CGDiscountSpecials start
 global $customer_id;
 if (tep_session_is_registered('customer_id')) {

by

 

 

I hope this were useful to you.

Share this post


Link to post
Share on other sites

FIRST: SORRY, I POSTED THE PATCH INCOMPLETELY, THE COMPLETE PATCH IS HERE.

 

 

Do I revert back to 1.3d and then apply that fix?

 

You have to revert this file:

 

/catalog/includes/classes/currencies.php,

 

to version 1.3e or 1.3d, i think its the same file:

 

 

Version 1.3e changelog:

 

v1.3e - by hOZONE

----

. fixed a bug in showing prices in:

.. catalog/includes/modules/new_products.php

 

 

This patch fix in:

 

catalog/includes/classes/currencies.php

catalog/shopping_cart.php

catalog/includes/boxes/shopping_cart.php

 

 

This patch will work on both versions, 1.3e and 1.3d

 

 

update for CGDiscountSpecials 1.3d
by BigT

features :
- Enables admin to choose wether a default price should be accessible by guests.

description :
- true/false choice for "allow guest to see prices" property in admin >> configuration >> my store
- prices displayed will be computed from rules defined for group 'default'

support :
- it works fine for me but i don't give money back if it doesn't work for you :)
- still, if i have time, i might answer to emails sent to bigtiti@hotmail.com
- enjoy

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

in file catalog/includes/classes/currencies.php

replace

//CGDiscountSpecials start
   function display_price($products_price, $products_tax, $quantity = 1) {
     global $customer_id;
     if (tep_session_is_registered('customer_id')) {

by

   function display_price($products_price, $products_tax, $quantity = 1) {
     global $customer_id;
     $myQuery = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " WHERE configuration_key = 'ALLOW_GUEST_TO_SEE_PRICES'");
     $myQuery_result = tep_db_fetch_array($myQuery);      
     if ($myQuery_result['configuration_value']=='true' || tep_session_is_registered('customer_id')) {

and replace

   function display_price_nodiscount($products_price, $products_tax, $quantity = 1) {
     global $customer_id;
     if (tep_session_is_registered('customer_id')) {

by

   function display_price_nodiscount($products_price, $products_tax, $quantity = 1) {
     global $customer_id;
     $myQuery = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " WHERE configuration_key = 'ALLOW_GUEST_TO_SEE_PRICES'");
     $myQuery_result = tep_db_fetch_array($myQuery);
     if ($myQuery_result['configuration_value']=="true" || tep_session_is_registered('customer_id')) {

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

in file catalog/shopping_cart.php

replace

         //CGDiscountSpecials start
         global $customer_id;
         if (tep_session_is_registered('customer_id')) {

by

         //CGDiscountSpecials start
         global $customer_id;
         $myQuery = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " WHERE configuration_key = 'ALLOW_GUEST_TO_SEE_PRICES'");
         $myQuery_result = tep_db_fetch_array($myQuery);      
         if ($myQuery_result['configuration_value']=='true' || tep_session_is_registered('customer_id')) {

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

in file catalog/includes/boxes/shopping_cart.php

replace

 //CGDiscountSpecials start
 global $customer_id;
 if (tep_session_is_registered('customer_id')) {

by

 //CGDiscountSpecials start
 global $customer_id;
 $myQuery = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " WHERE configuration_key = 'ALLOW_GUEST_TO_SEE_PRICES'");
 $myQuery_result = tep_db_fetch_array($myQuery);      
 if ($myQuery_result['configuration_value']=='true' || tep_session_is_registered('customer_id')) {

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

run this query :

INSERT INTO `configuration` (`configuration_id`, `configuration_title`, `configuration_key`, `configuration_value`, `configuration_description`, `configuration_group_id`, `sort_order`, `last_modified`, `date_added`, `use_function`, `set_function`) VALUES ('', 'Allow Guest To See Prices', 'ALLOW_GUEST_TO_SEE_PRICES', 'true', 'Allow guests to view default prices', '1', '0', '', '2004-03-15 14:59:05', NULL, 'tep_cfg_select_option(array(\'true\', \'false\'),');

Share this post


Link to post
Share on other sites

I applied the code, and the custommers can now see the pricing in the database , but I would like them to see the pricing of the defualt group wich is at +35% how can I acomplish this?

Share this post


Link to post
Share on other sites

I guess I would have to learn php to get it to work. Dang I was kind of hoping some one would figure that out.

Share this post


Link to post
Share on other sites

version 1.4 is out

 

v1.4 - by hOZONE

----

. apply the hack from BigT(bigtiti@hotmail.com) to allow guest to see prices,

changed files are:

. catalog/includes/classes/currencies.php

. catalog/includes/boxes/shopping_cart.php

. catalog/shopping_cart.php

added a value in the sql CGDiscountSpecials.sql file:

. INSERT INTO `configuration` (`configuration_id`, `configuration_title`, `configuration_key`, `configuration_value`, `configuration_description`, `configuration_group_id`, `sort_order`, `last_modified`, `date_added`, `use_function`, `set_function`) VALUES ('', 'Allow Guest To See Prices', 'ALLOW_GUEST_TO_SEE_PRICES', 'false', 'Allow guests to view default prices', '1', '31', '', '2004-03-15 14:59:05', NULL, 'tep_cfg_select_option(array(\'true\', \'false\'),');


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

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  

×