Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Seperate Pricing Per Customer v3.5


scendent

Recommended Posts

It's a MySQL4 error :)

 

See this post for a fix (two actually).

 

Hi JanZ

 

Thank you for helping so quickly, that has fixed it fine. I found the missing > too, Firefox was OK but in IE the save button was missing.

 

Is it possible also to have the drop down menu for the attributes showing the actual amount rather than + or - the catalog item?

 

With very grateful thanks

Katie

Link to comment
Share on other sites

Hi Jan,

 

I'm having fun trying to code something :blush: Here is my logic:

 

1. Check if coupon code is 'PACKET' - looks like we have that

2. Set packet_array - looks like we have that

3. Get array of product_id in the cart - not sure if I have that

4. Check to see that product_id 206 is in the array from the cart - (I think I have this) if it is, then

5. Check to see if more than 0 product_id from packet_array are in the array from the cart (I think I have this)

 

If 4 or 5 are not in the cart then it returns an error (looks like we have this)

 

Somewhere between steps 3&5 (or all three of those steps) I'm missing something.

 

How would you go about getting the array of product id's that are in the shopping cart? This is being called by checkout_confirmation after you enter your payment info and click to continue. If it returns an error then you are redirected to the payment or shipping pages depending on the error - otherwise you get to go to the confirmation page.

 

So - right now I have this:

function packet_coupon( $products = array() ) {
global $cart;
  if( strtolower( $this->coupon['coupons_id'] ) == strtolower( 'PACKET' ) ) { //strtolower() to avoid case issues
  $packet_array = array( 158, 159, 150, 151, 156, 157, 172, 173, 174, 208, 164, 165, 213, 202 ); //array of valid ids to use with this coupon
  $this->cart_info['products_id'] = $product_ids;
  $product_ids = array(); //we need to get an array of the products ids in the cart
  for( $i = 0; $i < count( $product_ids ); $i++ ) {
	$this->cart_info['products_id']['count'] += $product_ids[$i]['quantity'];
	}
  //now that we have a complete array of product ids, make sure our required products are in it
  if( !in_array( 206, $product_ids )) { //if 206 is not of our items, or there are no acceptable products in the cart, then we can't allow the coupon
	$this->message( ENTRY_DISCOUNT_COUPON_PACKET_ERROR ); // replace with packet error	
	} else if( !in_array( count( $packet_array ) > 0, $product_ids )) { // if more than 0 products from packet_array are not in cart then we can't allow the coupon
	$this->message( ENTRY_DISCOUNT_COUPON_PACKET_ERROR );	
}// end if !in_array
}// end if( strtolower
}//end function packet_coupon

 

Do you have any thoughts for me on how to make sure I get the array of product_id's from the cart? Or do you see me doing something strange in there? :blush:

~Tracy
 

Link to comment
Share on other sites

Is it possible also to have the drop down menu for the attributes showing the actual amount rather than + or - the catalog item?
I have no personal experience with any of them but doing a search on the contribution site gave me two candidates: Actualy Price in Pull down option menus and Actual Attribute Price V1.0.
Link to comment
Share on other sites

JanZ,

 

I am trying to integrate your SPPC into a shop with multi stores on it. I modified all the files but am having problems figuring out where/how I need to modify the statements to account for the multi stores. The first error I get in from the index.php page when I click on any product.

 

 

1054 - Unknown column 's.stores_id' in 'on clause'

 

select count(p.products_id) as total from products_description pd, products p left join manufacturers m on p.manufacturers_id = m.manufacturers_id, products_to_categories p2c left join specials_retail_prices s on p.products_id = s.products_id and s.stores_id = '1' INNER JOIN products_to_stores p2s ON p.products_id = p2s.products_id where p2s.stores_id = '1' and p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '1' and p2c.categories_id = '25'

 

[TEP STOP]

 

I just don't even know where to start on this. Any help would be greatly appreciated from anyone.

 

Thanks!

 

Joanne

Link to comment
Share on other sites

If you go back to my original post with the fixes you will see that there are three more places where a [$x] were added. I think you oversaw that :)

 

Ah yes, i did indeedy, forgot to change the other $listing references to $listing[$x]

 

You're a legend! :)

 

While im here, there's also a small problem logging in as the admin SPPC account which brings up the white page with the different customer groups to login as for testing. Here's the link that appears on that screen:

 

and here's the link after the continue button (which ahs a broken image link) is pressed:

 

 

It just stays on the same screen though after you select a group and hit the continue button. Doesnt seem to go back to the site and even if you manually browse back to the site, the admin isn't logged in. Any ideas what to look into?

 

One more thing and im sure this has been answered before. What changes do i make to featured.php for the customer group prices to change on the front page where Featured Products are displayed? Could anyone even point me to the page of this thread that this is on?

 

Thanks for the help everyone, this is a great mod!

 

JanZ, have you looked at Zencart v1.3.7 yet? Im absolutely gobsmacked by the amount of features that they now have in that software compared to even whats being planned for osC v3. Group pricing, featured products, multiple products images plus lots more is standard in Zencart now! The osC team have some catching up to do and i noticed in a post that they weren't that pushed about group pricing being in osC v3! Can you please push for your mod to be the one that gets used coz they'd be making a big mistake not to. Great mod, great support, great work! :thumbsup:

Link to comment
Share on other sites

I have no personal experience with any of them but doing a search on the contribution site gave me two candidates: Actualy Price in Pull down option menus and

 

Hi JanZ

 

I only need the most simple solution to show the actual prices in the attributes, so Actualy Price in Pull Down... would work fine. The changes/code is really simple but instructions don't account for SPPC already installed. I'm not familar with SPPC code and I'd be very grateful if you could help with the changes. The contributions states changes:

In catalog/product_info.php

Look for:

   if ($products_options['options_values_price'] != '0') {
       $products_options_array[sizeof($products_options_array)-1]['text'] .= ' ('

       . $products_options['price_prefix']

       . $currencies->display_price(

    $products_options['options_values_price'],

           tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
   }




Change to: 

//// BOF Actual Price Pull Down v1.2.3a
$new_price ? $original_price = $new_price : $original_price = $product_info['products_price']; //// check if set special price

       $option_price = $products_options['options_values_price'];
       if ($products_options['price_prefix'] == "-") // in case price lowers, don't add values, subtract.
  {
	$show_price = 0.0 + $original_price - $option_price; // force float (in case) using the 0.0;
  } else {
       	 $show_price = 0.0 + $original_price + $option_price; // force float (in case) using the 0.0;
  }
   if ($products_options['options_values_price'] != '0') {
       $products_options_array[sizeof($products_options_array)-1]['text'] .= ' ('
       . $currencies->display_price( $show_price, tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
}
//// EOF Actual Price Pull Down v1.2.3a

 

The if statement mentioned is, I believe, SPPC changed (lines approx 189-191)

		  if ($products_options[$n]['options_values_price'] != '0') {
           $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options[$n]['price_prefix'] . $currencies->display_price($products_options[$n]['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
         }

 

I tried just adding the amended bit before line 189 but this did nothing

$new_price ? $original_price = $new_price : $original_price = $product_info['products_price']; //// check if set special price

       $option_price = $products_options['options_values_price'];
       if ($products_options['price_prefix'] == "-") // in case price lowers, don't add values, subtract.
  {
	$show_price = 0.0 + $original_price - $option_price; // force float (in case) using the 0.0;
  } else {
       	 $show_price = 0.0 + $original_price + $option_price; // force float (in case) using the 0.0;
  }

 

If you are able to advise the changes necessary to make this work it would be a fantastic help.

Many thanks

Katie

Link to comment
Share on other sites

I tried just adding the amended bit before line 189 but this did nothing

I think if you add [$n] in the appropriate places (it is in a for loop instead of a while loop) it should work:

$new_price ? $original_price = $new_price : $original_price = $product_info['products_price']; //// check if set special price

	$option_price = $products_options[$n]['options_values_price'];
	if ($products_options[$n]['price_prefix'] == "-") // in case price lowers, don't add values, subtract.
  {
	$show_price = 0.0 + $original_price - $option_price; // force float (in case) using the 0.0;
  } else {
		 $show_price = 0.0 + $original_price + $option_price; // force float (in case) using the 0.0;
  }

Link to comment
Share on other sites

It just stays on the same screen though after you select a group and hit the continue button. Doesnt seem to go back to the site and even if you manually browse back to the site, the admin isn't logged in. Any ideas what to look into?
The SEO code cannot cope with the additional GET parameter that is added. If you use POST parameters instead like mentioned in this post you should be fine.
One more thing and im sure this has been answered before. What changes do i make to featured.php for the customer group prices to change on the front page where Featured Products are displayed? Could anyone even point me to the page of this thread that this is on?
That post was mentioned very recently, go back in this thread a bit or search for "featured".

 

JanZ, have you looked at Zencart v1.3.7 yet? Im absolutely gobsmacked by the amount of features that they now have in that software compared to even whats being planned for osC v3. Group pricing, featured products, multiple products images plus lots more is standard in Zencart now! The osC team have some catching up to do and i noticed in a post that they weren't that pushed about group pricing being in osC v3! Can you please push for your mod to be the one that gets used coz they'd be making a big mistake not to.
No, I never looked at Zencart I think. A. I don't have the time and B. I don't believe in these beefed up osC versions, I always think they contain too much stuff you don't want to use anyway. Although the things you mention are an exception to that rule ;)

Regarding adding group pricing in osC, it is not my call. I'm sure Harald will have noticed what Zencart is doing (and I think another one exists X-cart perhaps that has group pricing in it?) so if he wants it in he can do it. I guess there is still plenty of time for that decision ;)

Link to comment
Share on other sites

I am trying to integrate your SPPC into a shop with multi stores on it. I modified all the files but am having problems figuring out where/how I need to modify the statements to account for the multi stores. The first error I get in from the index.php page when I click on any product.

I just don't even know where to start on this. Any help would be greatly appreciated from anyone.

Looks more like the MySQL5 problem to me. Check the latest version of osC and see what has changed in the query for the index.php or look at the version for SPPC in this post on page 122.
Link to comment
Share on other sites

I think if you add [$n] in the appropriate places (it is in a for loop instead of a while loop) it should work:

for ($n = 0 ; $n < count($products_options); $n++) {
         $products_options_array[] = array('id' => $products_options[$n]['products_options_values_id'], 'text' => $products_options[$n]['products_options_values_name']);
	  //Start Actual Prices in Drop Down
	  $new_price ? $original_price = $new_price : $original_price = $product_info['products_price']; //// check if set special price
       $option_price = $products_options[$n]['options_values_price'];
       if ($products_options[$n]['price_prefix'] == "-") // in case price lowers, don't add values, subtract.
     {
       $show_price = 0.0 + $original_price - $option_price; // force float (in case) using the 0.0;
     } else {
            $show_price = 0.0 + $original_price + $option_price; // force float (in case) using the 0.0;
     } //end actual prices in drop down
         		  if ($products_options[$n]['options_values_price'] != '0') {
           $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options[$n]['price_prefix'] . $currencies->display_price($products_options[$n]['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
         }
       }

 

Thank you again for your help here.

Katie

Link to comment
Share on other sites

I don't really understand why but it isn't working, it's not returning any errors, the attributes still have the + or - amount as normal. It's simple code so is it just that a variable is named incorrectly? I'm afraid I can't see what it might be.
You didn't follow all the instructions of the Actual price in dropdown contribution. This works fine for me (note the use of $show_price and deletion of price_prefix):

   for ($n = 0; $n < count($products_options); $n++) {
	  $products_options_array[] = array('id' => $products_options[$n]['products_options_values_id'], 'text' => $products_options[$n]['products_options_values_name']);
		// BOF Actual price in dropdown
		$new_price ? $original_price = $new_price : $original_price = $product_info['products_price']; //// check if set special price

	$option_price = $products_options[$n]['options_values_price'];
	if ($products_options[$n]['price_prefix'] == "-") // in case price lowers, don't add values, subtract.
  {
	$show_price = 0.0 + $original_price - $option_price; // force float (in case) using the 0.0;
  } else {
		 $show_price = 0.0 + $original_price + $option_price; // force float (in case) using the 0.0;
  }
	  if ($products_options[$n]['options_values_price'] != '0') {
		$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' .  $currencies->display_price($show_price, tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
	  }
	}
// EOF SPPC attributes mod EOF Actual price in dropdown

Link to comment
Share on other sites

You didn't follow all the instructions of the Actual price in dropdown contribution. This works fine for me (note the use of $show_price and deletion of price_prefix):

   for ($n = 0; $n < count($products_options); $n++) {
	  $products_options_array[] = array('id' => $products_options[$n]['products_options_values_id'], 'text' => $products_options[$n]['products_options_values_name']);
		// BOF Actual price in dropdown
		$new_price ? $original_price = $new_price : $original_price = $product_info['products_price']; //// check if set special price

	$option_price = $products_options[$n]['options_values_price'];
	if ($products_options[$n]['price_prefix'] == "-") // in case price lowers, don't add values, subtract.
  {
	$show_price = 0.0 + $original_price - $option_price; // force float (in case) using the 0.0;
  } else {
		 $show_price = 0.0 + $original_price + $option_price; // force float (in case) using the 0.0;
  }
	  if ($products_options[$n]['options_values_price'] != '0') {
		$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' .  $currencies->display_price($show_price, tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
	  }
	}
// EOF SPPC attributes mod EOF Actual price in dropdown

 

Hi JanZ

 

That works perfectly, thank you so much :)

Katie

Link to comment
Share on other sites

JanZ,

 

I checked the version of the software on the server.

 

PHP version 4.4.4

MySQL version 4.1.21-standard

 

So it's not a MySQL 5 issue. Any other thoughts?

 

Thanks!

 

Joanne

Link to comment
Share on other sites

There is an awful lot wrong with that piece of code Tracy. Too much to go into that right now. Has to wait till tomorrow at least.

 

LOL - Well, I picked up another stack of books this weekend - so maybe I can figure it out with those :thumbsup:

 

In the meantime I do have something I'm stuck on. I have the Hide Products/Categories for SPPC installed, and it is working just fine for the slave products, but when I choose to hide a Master Product it isn't holding the hide status on the admin/categories.php page - it's not writing it to the database. If I change it manually in the database it works, but I'm missing something in my admin/categories.php that sends it to the database.

 

Could you let me know which bit of code is doing this for normal products so I can check my master products section to see if it's missing? I've been through the install instructions several times - I've re-created the page starting with the one in the Hide Products/Categories for SPPC and then adding in Master Products (and a few other contrib's that edit it) and I still have the same problem :huh: I figure since I've spent the entire day on this so far I'll break down and ask - LOL :blush:

~Tracy
 

Link to comment
Share on other sites

You were right about the typo. It is still a hack: it mentions results 1-20 and there are only like 5, so it would be better to change the sql (if that is possible in this case...).

 

Don't have any time to look at it though right now...

 

Hi Janz, It's me again.

 

Sorry to bother you. I understand you are very busy. I have a tiny problem. I hope you know how to fix it.

Where were we? Last time, you helped fix my problem regarding "product-listing". It worked all the way.

Below was the screen of the result.

listing4.gif

 

As my OSCommerce is configured to allow different groups of customers to register by keying in a special code that I gave them in advance before they registered, when they log in as, say group 3 customer, they could see the special prices for them. Here below is the screen of what they see.

listing5.gif

 

As you can see, always a few lines of special prices are missing from the bottom. However, when you click in the product_info page, its normal. Even when you click at the "Buy Now" button on the product_listing page, it's also normal. That is, the prices of products found in the shopping cart are the discounted prices already.

 

I think it's ONLY a problem of display matter. Can you figure out why this occurred? And, could you give me some hints which files should I look into? Thanks in advance. Hope you will find some time looking into this.

 

Cheers

 

James

Link to comment
Share on other sites

It's a MySQL4 error :)

 

Hi JanZ

 

Testing has highlighted a further error showing on advanced_search_results.php

 

1066 - Not unique table/alias: 'pd'

select count(distinct p.products_id) as total from products p left join manufacturers m using(manufacturers_id), products_description pd left join specials s on p.products_id = s.products_id, categories c, products_to_categories p2c, products_description pd, categories c, products_to_categories p2c where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and ((pd.products_name like '%world%' or p.products_model like '%world%' or m.manufacturers_name like '%world%' or pd.products_description like '%world%') and (pd.products_name like '%glass%' or p.products_model like '%glass%' or m.manufacturers_name like '%glass%' or pd.products_description like '%glass%') and (pd.products_name like '%plaque%' or p.products_model like '%plaque%' or m.manufacturers_name like '%plaque%' or pd.products_description like '%plaque%') )

[TEP STOP]

 

Is it possible that this is also a MYSQL4 error? I'd be very grateful if you are able to help with this too.

 

If relevant this is my server set up:

PHP version 4.4.4

MySQL version 4.1.21-standard

Many thanks

Katie

Link to comment
Share on other sites

Testing has highlighted a further error showing on advanced_search_results.php

 

1066 - Not unique table/alias: 'pd'

select count(distinct p.products_id) as total from products p left join manufacturers m using(manufacturers_id), products_description pd left join specials s on p.products_id = s.products_id, categories c, products_to_categories p2c, products_description pd, categories c, products_to_categories p2c where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and ((pd.products_name like '%world%' or p.products_model like '%world%' or m.manufacturers_name like '%world%' or pd.products_description like '%world%') and (pd.products_name like '%glass%' or p.products_model like '%glass%' or m.manufacturers_name like '%glass%' or pd.products_description like '%glass%') and (pd.products_name like '%plaque%' or p.products_model like '%plaque%' or m.manufacturers_name like '%plaque%' or pd.products_description like '%plaque%') )

[TEP STOP]

 

Is it possible that this is also a MYSQL4 error?

No, I checked the SPPC415 version of advanced_search_results.php now and that is causing the problem. Better use the 4.11 version of that page and add the MySQL5 fixes mentioned in this post on page 122.
Link to comment
Share on other sites

As my OSCommerce is configured to allow different groups of customers to register by keying in a special code that I gave them in advance before they registered, when they log in as, say group 3 customer, they could see the special prices for them. Here below is the screen of what they see.

 

As you can see, always a few lines of special prices are missing from the bottom.

I don't see (code wise) how this could happen unless you are missing all the special prices and group prices for your customers group 3. In that case the missing global $sppc_customer_group_id might be the culprit.

 

Try changing the:

  if(!tep_session_is_registered('sppc_customer_group_id')) { 
 $customer_group_id = '0';
 } else {
  $customer_group_id = $sppc_customer_group_id;
 }

to the more reliable:

  if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') {
 $customer_group_id = $_SESSION['sppc_customer_group_id'];
 } else {
  $customer_group_id = '0';
 }

Link to comment
Share on other sites

I checked the version of the software on the server.

 

PHP version 4.4.4

MySQL version 4.1.21-standard

 

So it's not a MySQL 5 issue. Any other thoughts?

Looking more closely I saw there is an s.stores_id that is supposed to be in specials_retail_prices. However, that table does not contain a stores_id. I don't know how multiple stores is working but if you need that you have to change the code for function tep_db_check_age_specials_retail_table in catalog/includes/functions/database.php and add that column there and change the code for inserting prices. You can delete (drop) the table if you like, it will be made again when a retail customer clicks on sorting by price (or uses search by price in advanced_search.php).
Link to comment
Share on other sites

I have the Hide Products/Categories for SPPC installed, and it is working just fine for the slave products, but when I choose to hide a Master Product it isn't holding the hide status on the admin/categories.php page - it's not writing it to the database. If I change it manually in the database it works, but I'm missing something in my admin/categories.php that sends it to the database.
I guess you added the "hide processing" in admin/categories.php under case 'update_products' but not a little further on case 'update_master' (pretty much identical).
Link to comment
Share on other sites

I'm having fun trying to code something

Here is my logic:

 

1. Check if coupon code is 'PACKET' - looks like we have that

2. Set packet_array - looks like we have that

3. Get array of product_id in the cart - not sure if I have that

4. Check to see that product_id 206 is in the array from the cart - (I think I have this) if it is, then

5. Check to see if more than 0 product_id from packet_array are in the array from the cart (I think I have this)

 

If 4 or 5 are not in the cart then it returns an error (looks like we have this)

 

Somewhere between steps 3&5 (or all three of those steps) I'm missing something.

 

How would you go about getting the array of product id's that are in the shopping cart? This is being called by checkout_confirmation after you enter your payment info and click to continue. If it returns an error then you are redirected to the payment or shipping pages depending on the error - otherwise you get to go to the confirmation page.

 

So - right now I have this:

>_<

function packet_coupon( $products = array() ) {

Now why do you use that when you only (try to) use items from objects that you use inside the function?

	global $cart;

Sure about that? checkout_confirmation.php seems to use the object $order.

	  if( strtolower( $this->coupon['coupons_id'] ) == strtolower( 'PACKET' ) ) { //strtolower() to avoid case issues

Is this inside a class? Which class? Anyway, the $this refers to the class of which the function is part of. You however seem to mix $this of the class order, cart and you might not even be in a class...

	  $packet_array = array( 158, 159, 150, 151, 156, 157, 172, 173, 174, 208, 164, 165, 213, 202 ); //array of valid ids to use with this coupon
  $this->cart_info['products_id'] = $product_ids;

I guess you are referering to the object $order but that has $order->products that hold info on that...

	  $product_ids = array(); //we need to get an array of the products ids in the cart

No, you just emptied that array with this statement.

	  for( $i = 0; $i < count( $product_ids ); $i++ ) {
	$this->cart_info['products_id']['count'] += $product_ids[$i]['quantity'];

I doubt $this->cart_info exists but I might be wrong

		}
  //now that we have a complete array of product ids, make sure our required products are in it
  if( !in_array( 206, $product_ids )) { //if 206 is not of our items, or there are no acceptable products in the cart, then we can't allow the coupon
	$this->message( ENTRY_DISCOUNT_COUPON_PACKET_ERROR ); // replace with packet error	
	} else if( !in_array( count( $packet_array ) > 0, $product_ids )) { // if more than 0 products from packet_array are not in cart then we can't allow the coupon

??? count($packet_array) would give 14 (number of items in that array) so this makes no sense. Anyway, you can't have zero products in the shopping cart so you only have to look if an item in the order is in that list.

Link to comment
Share on other sites

I guess you added the "hide processing" in admin/categories.php under case 'update_products' but not a little further on case 'update_master' (pretty much identical).

 

I thought something like that too - but update_product and update_master seem to be identical :huh:

 

Here's my update_master - do you see anything missing?

 

//Master Products		
   case 'insert_master':
   case 'update_master':

	if (isset($HTTP_POST_VARS['edit_x']) || isset($HTTP_POST_VARS['edit_y'])) {
	  $action = 'new_master';
	} else {
	  if (isset($HTTP_GET_VARS['pID'])) $products_id = tep_db_prepare_input($HTTP_GET_VARS['pID']);
	  $products_date_available = tep_db_prepare_input($HTTP_POST_VARS['products_date_available']);

	  $products_date_available = (date('Y-m-d') < $products_date_available) ? $products_date_available : 'null';
	  $products_master_status = '1';

	  // BOF Separate Pricing Per Customer, hide products and categories from groups
$hide_from_these_groups = '@,';
		 if ( $HTTP_POST_VARS['hide'] ) { // if any of the checkboxes are checked
			   foreach($HTTP_POST_VARS['hide'] as $val) {
			   $hide_from_these_groups .= tep_db_prepare_input($val).','; 
			   } // end foreach
		   }
$hide_from_these_groups = substr($hide_from_these_groups,0,strlen($hide_from_these_groups)-1); // remove last comma
// EOF Separate Pricing Per Customer, hide products and categories from groups

	  $sql_data_array = array('products_quantity' => tep_db_prepare_input($HTTP_POST_VARS['products_quantity']),
							  'products_model' => tep_db_prepare_input($HTTP_POST_VARS['products_model']),
							  'products_price' => tep_db_prepare_input($HTTP_POST_VARS['products_price']),
							  'products_date_available' => $products_date_available,
							  'products_status' => tep_db_prepare_input($HTTP_POST_VARS['products_status']),
							  'products_master_status' => tep_db_prepare_input($HTTP_POST_VARS['products_master_status']),
							  'products_tax_class_id' => tep_db_prepare_input($HTTP_POST_VARS['products_tax_class_id']),
						 //BOF Separate Price Per Customer, hide for these groups modification
							  'products_hide_from_groups' => $hide_from_these_groups,
						//EOF Separate Price Per Customer, hide for these groups modification
							  'manufacturers_id' => tep_db_prepare_input($HTTP_POST_VARS['manufacturers_id']),
						// BOF Product Sort
							  'products_sort_order' => tep_db_prepare_input($HTTP_POST_VARS['products_sort_order']));
						// EOF Product Sort


	  if (isset($HTTP_POST_VARS['products_image']) && tep_not_null($HTTP_POST_VARS['products_image']) && ($HTTP_POST_VARS['products_image'] != 'none')) {
		$sql_data_array['products_image'] = tep_db_prepare_input($HTTP_POST_VARS['products_image']);
	  }

	  if ($action == 'insert_master') {
		$insert_sql_data = array('products_date_added' => 'now()');

		$sql_data_array = array_merge($sql_data_array, $insert_sql_data);

		tep_db_perform(TABLE_PRODUCTS, $sql_data_array);
		$products_id = tep_db_insert_id();

		tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$products_id . "', '" . (int)$current_category_id . "')");
		// BOF Separate Pricing Per Customer originally 2006-04-26 by Infobroker
  $cg_price_query = tep_db_query("select customers_group_id, customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . $products_id . "' order by customers_group_id");

// insert customer group prices in table products_groups when there are any for the copied product
if (tep_db_num_rows($cg_price_query) > 0) {
  while ( $cg_prices = tep_db_fetch_array($cg_price_query)) {
	tep_db_query("insert into " . TABLE_PRODUCTS_GROUPS . " (customers_group_id, customers_group_price, products_id) values ('" . (int)$cg_prices['customers_group_id'] . "', '" . tep_db_input($cg_prices['customers_group_price']) . "', '" . (int)$dup_products_id . "')");
  } // end while ( $cg_prices = tep_db_fetch_array($cg_price_query))
} // end if (tep_db_num_rows($cg_price_query) > 0)

// EOF Separate Pricing Per Customer originally 2006-04-26 by Infobroker

	  } elseif ($action == 'update_master') {
		$update_sql_data = array('products_last_modified' => 'now()');

		$sql_data_array = array_merge($sql_data_array, $update_sql_data);

		tep_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "'");
	  }

// BOF Separate Pricing Per Customer
		$customers_group_query = tep_db_query("select customers_group_id, customers_group_name from " . TABLE_CUSTOMERS_GROUPS . " where customers_group_id != '0' order by customers_group_id");
		while ($customers_group = tep_db_fetch_array($customers_group_query)) // Gets all of the customers groups
	  {
		$attributes_query = tep_db_query("select customers_group_id, customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where ((products_id = '" . $products_id . "') && (customers_group_id = " . $customers_group['customers_group_id'] . ")) order by customers_group_id");
		$attributes = tep_db_fetch_array($attributes_query);
		if (tep_db_num_rows($attributes_query) > 0) {
		if ($HTTP_POST_VARS['sppcoption'][$customers_group['customers_group_id']]) { // this is checking if the check box is checked
		if ( ($HTTP_POST_VARS['sppcprice'][$customers_group['customers_group_id']] <> $attributes['customers_group_price']) && ($attributes['customers_group_id'] == $customers_group['customers_group_id']) ) {
	tep_db_query("update " . TABLE_PRODUCTS_GROUPS . " set customers_group_price = '" . $HTTP_POST_VARS['sppcprice'][$customers_group['customers_group_id']] . "' where customers_group_id = '" . $attributes['customers_group_id'] . "' and products_id = '" . $products_id . "'");
		$attributes = tep_db_fetch_array($attributes_query);
	  }
		elseif (($HTTP_POST_VARS['sppcprice'][$customers_group['customers_group_id']] == $attributes['customers_group_price'])) {
	$attributes = tep_db_fetch_array($attributes_query);
	  }
	 } else {
		tep_db_query("delete from " . TABLE_PRODUCTS_GROUPS . " where customers_group_id = '" . $customers_group['customers_group_id'] . "' and products_id = '" . $products_id . "'");
		$attributes = tep_db_fetch_array($attributes_query);
	  }
	 }
	  elseif (($HTTP_POST_VARS['sppcoption'][$customers_group['customers_group_id']]) && ($HTTP_POST_VARS['sppcprice'][$customers_group['customers_group_id']] != '')) {
	   tep_db_query("insert into " . TABLE_PRODUCTS_GROUPS . " (products_id, customers_group_id, customers_group_price) values ('" . $products_id . "', '" . $customers_group['customers_group_id'] . "', '" . $HTTP_POST_VARS['sppcprice'][$customers_group['customers_group_id']] . "')");
	   $attributes = tep_db_fetch_array($attributes_query);
	 }

	 }
// EOF Separate Pricing Per Customer

	  $languages = tep_get_languages();
	  for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
		$language_id = $languages[$i]['id'];

		$sql_data_array = array('products_name' => tep_db_prepare_input($HTTP_POST_VARS['products_name'][$language_id]),
								'products_description' => tep_db_prepare_input($HTTP_POST_VARS['products_description'][$language_id]),
								'products_url' => tep_db_prepare_input($HTTP_POST_VARS['products_url'][$language_id]));

		if ($action == 'insert_master') {
		  $insert_sql_data = array('products_id' => $products_id,
								   'language_id' => $language_id);

		  $sql_data_array = array_merge($sql_data_array, $insert_sql_data);

		  tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array);
		} elseif ($action == 'update_master') {
		  tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "' and language_id = '" . (int)$language_id . "'");
		}
	  }

	  if (USE_CACHE == 'true') {
		tep_reset_cache_block('categories');
		tep_reset_cache_block('also_purchased');
	  }

	  tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products_id));
	}
	break;
// Master Products EOF

~Tracy
 

Link to comment
Share on other sites

I thought something like that too - but update_product and update_master seem to be identical :huh:

 

Here's my update_master - do you see anything missing?

Well no actually. I do assume the hide checkboxes are also shown when you edit a master?

 

Otherwise try to print_r the HTTP_POST_VARS and/or echo the $hide_from_these_groups before an exit(); Then you know a bit more I hope.

Link to comment
Share on other sites

Well no actually. I do assume the hide checkboxes are also shown when you edit a master?

 

Otherwise try to print_r the HTTP_POST_VARS and/or echo the $hide_from_these_groups before an exit(); Then you know a bit more I hope.

 

Yes - the checkboxes are there and I can check them - it just doesn't post that it's been checked to the database :huh:

 

I sort of understand what you want me to print - but I'm not sure how to do it. Could you show me an example of what would go in print_r($*this spot) to print the HTTP_POST_VARS ?

 

Thanks!

~Tracy
 

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