Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[contribution] CGDiscountSpecials


hozone

Recommended Posts

I am new to MySql and I can not figure out where to run this portion of the install

 

Installation

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

1) run the .sql file in the folder "Sql" of this file to apply SQL changes to your database.

Where do I put this file to alter my database? Thank y ou for any help I ahev been at it for hours to no avail I keep getting this error

 

Groups

1146 - Table 'scrapcents_db.customers_groups' doesn't exist

select count(*) as total from customers_groups g

 

[TEP STOP]

If you have something like a cpanel or phpMyadmin you can run this statement from there.

 

select SQL from phpMyadmii and use the browse sql file button to pick this file and run it.

 

You can also copy and past the statement directly into the query window.

Link to comment
Share on other sites

  • Replies 126
  • Created
  • Last Reply

Top Posters In This Topic

when you goto phpMyAdmin you should have your current databases listed by clicking on databases below the create field you are talking about.

 

Click on the database that has your store in it and then it will list all your tables. Click on the SQL tab (second from right) and then you can run your sql file.

 

I am sure there is alot of help in the general topics here on phpmyAdmin

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

I ♥ PHP/MYSQL/CSS

Link to comment
Share on other sites

I tested it with Allow Guests to See Prices True and False and it works fine on mine. Keep in mind I'm a newbie so hopefully one of you php code professionals can review what I did and verify that the code works like it should.

 

 

From my earlier post about not having the totals on Checkout_Confirmation.php working...I was able to get the totals showing up perfectly on a new MS2 install. I must have missed some code when I installed it on my heavily modified version.

 

 

Also, I was looking at the code and since i'm a newbie on php what code would I need to change to make it choose the least of between Special Price and Regular Price with Discount? This will make the Specials Prices blend seamlessly with this mode. It looks weird when I have a sale price for an item as $80 and the signed in customers see $90. And I wouldn't want to sign up an additional special price for each groups and individuals getting discounts.

 

 

So far this contrib is like 98% complete. Thanks Hozone for sharing it with everyone.

I ♥ PHP/MYSQL/CSS

Link to comment
Share on other sites

Hi,

Tried to install and am getting this error.

1054 - Unknown column 'c.customers_groups_id' in 'field list'

 

any ideas.

Colin :blink:

Link to comment
Share on other sites

I have a PROBLEM (big for me but surely easy for you to resolve :rolleyes: ) with CGDiscountSpecials 1.4b.

I installed osCommerce and CGDiscountSpecials. I have imported the new sql file CGDiscountSpecials.sql and ran it.

 

New table CUSTOMERS_GROUPS created with CUSTOMERS_GROUPS_ID, CUSTOMERS_GROUPS_NAME and CUSTOMERS_GROUPS_DISCOUNT. DEFAULT and WHOLESALE rows have been added.

 

CUSTOMERS table has a new row, CUSTOMERS_GROUPS_ID

 

SPECIALS table has a new rows, CUSTOMERS_GROUPS_ID and CUSTOMERS_ID

 

When I enter the shop as a Guest, I select a product and click buy and I have the following error:

 

1146 - Table 'shop_masy.table_customers_groups' doesn't exist

 

select g.customers_groups_discount from TABLE_CUSTOMERS_GROUPS g inner join customers c on g.customers_groups_id = c.customers_groups_id and c.customers_id = ''

 

[TEP STOP]

 

Do you guys have an idea ????????

THANKS IN ADVANCE !!!

Edited by Cisco_CH
Link to comment
Share on other sites

Just a minor issue really, I have installed oscms2 latest release and the newest version CGDiscountSpecials_1.4bfix clean install no problems.

 

Only 1 thing at the moment that is out of place, SPECIALS. I have altered admin to allow all to see prices and specials shows a price-ie 10.00 with a line strike through and underneath, 'please register to see prices?'

 

When I enable only registered members see prices in admin, specials has 2 strike through 'must be logged to see prices' so specials is a bit weird still.

 

Hope this helps debugging. :D

Link to comment
Share on other sites

Here is an example of what I mean, customer must login, here is a pic of the issue.

login%20enabled.gif

And here is a pic of the issue when customers dont need to login.

login%20disabled.gif

 

Hop ethese help to explain the issue to you gurus here. ;)

Link to comment
Share on other sites

Another variation of the problem when guests allowed to see prices function I get this in products page.

 

cgdiscount.gif

 

Anyone got a solution. plz. :D

Link to comment
Share on other sites

Ive got a largly modded osc ... but after some playing i belive I got everything working great with this. Big thanks to hOZONE for making this beautiful contrib.

 

I am wondering if there is a way to disable a discount for a specific item. For example I have gift certificates on my site - and having a discount price on gift certificates i believe leaves space for potential fradulent activity. I want discounts to apply to every item except gift certificates. Huge thanks in advance if anyone is able to make that work.

 

dilirum

Link to comment
Share on other sites

Thanks hozone. I'll consider that one ... just had another brainstorm of how it might work though. All though again - I have no idea how this might be implimented.

 

What if there was a "never lower than [price]" database field ... and it would be editable on a per item basis in admin/catagories.php.

 

This way if someone wanted to ensure that an item never drops below their cost - they could set it this way - or as well in my case to ensure that an items price doesn't change at all. ;)

 

Anyone have any idea on how to code that? And once again hozone... thanks for all your hard work on making such a well rounded contrib!

Link to comment
Share on other sites

Ive got a largly modded osc ... but after some playing i belive I got everything working great with this. Big thanks to hOZONE for making this beautiful contrib.

I too have a largely modified OSC - I DL'd this contribution and have taken a look at the files and the README. It seems as though a lot of my existing files are going to being replaced, rather than added to (if I simply copy them). I really want this contrib, but can't afford to bomb my current site by replacing files.

 

Are there any step-by-step instructions on *what* mods need to be performed to *what* files?

 

Thanks.

John Skurka

Link to comment
Share on other sites

DriWashSolutions ... doesn't appear that anyone has done that yet. I had to go through each file and search for any modifcations that related to this contrib. Each modification is labeled pretty good with :

 

//CGDiscountSpecials start

most files only have one instance of this. But look close ... cause there are a couple that have more than one.... and I missed the others the first time in a couple files... and the contrib didn't work. After I took a look at the files that ended up causing php errors... i quickly found the prob and completed the contrib. Worked like a champ then.

//CGDiscountSpecials end

 

IMHO it's a great contrib and still worth the hassle. Good luck!

 

dil :D

Link to comment
Share on other sites

... doesn't appear that anyone has done that yet.

Well, I've started writing a step by step instruction sheet, however I have one question: Has anyone got this contrib running in conjunction with STS?

 

I've got STS installed, so I want to make sure these two work together before I go any further. ;)

John Skurka

Link to comment
Share on other sites

I have sts and CGDiscounts working fine together for a long time and also added quite a number of other contribs to it so I wouldnt be too worried about sts and cdg go for it but BACKUP BACKUP BACKUP always.

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