Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Guest

Master Products - MS2

Recommended Posts

Try this first though, when you show a master product, add one to the product id in the url to see the slave product display, do the attributes show up?

 

Yes, this works.

Share this post


Link to post
Share on other sites

Eureka! Got it showing the attribute variable...

 

Only one problem. The drop down selection of the attribute (grind) is not making it into the cart.

 

Ryan, I got this working by using some code from your case 'MASTER_LIST_OPTIONS': in master_listing.php which was different from the other posted code in the way it handles id.

 

Why is the code not making it into the cart? Where should I look?

 

 

thanks

 

joe

Share this post


Link to post
Share on other sites
Guest

Joe

 

Good to see you're making progress. You're code looks ok. The only thing I can think of is you are using an older version of php.

 

The variable $_POST was only introduced with version 4.1 (I think). Before that you had to use $HTTP_POST_VARS to access posted variables.

 

I use $_POST in the 'add_slave' processing in application_top.php. It might be worth changing any instances of $_POST in application_top.php to $HTTP_POST_VARS.

 

Brian.

Share this post


Link to post
Share on other sites

Brian,

 

The only thing I can think of is you are using an older version of php.

 

The variable $_POST was only introduced with version 4.1 (I think). Before that you had to use $HTTP_POST_VARS to access posted variables.

 

I use $_POST in the 'add_slave' processing in application_top.php. It might be worth changing any instances of $_POST in application_top.php to $HTTP_POST_VARS.

 

I use version 4.3.4 (Zend: 1.3.0) and I am using $HTTP_POST_VARS in application_top.

 

Where exactly is the id variable passed for insertion? Does this seem like a problem in application_top, master_listing or where.

 

I can see all the variables when I use the browser info. So obviously it's just not making it to the cart.

Any debug trick you can recommend to pin down my "typo?"

 

Thanks for the help, Brian.

 

 

joe

Share this post


Link to post
Share on other sites

I like using echo a lot in all my if statements to see if its getting in there and also whether I am getting a value for a variable when I am custom coding. You can't really do it in application top unless you take out the page redirect (I think it's in there) but I used it in shopping_cart a lot. Also view the source of product_info to make sure the values are filled in properly.

 

Other than that, just compare my code with yours and see if you can spot a difference.

 

Ryan


If I was crafty, this would be a funny signature.

Share this post


Link to post
Share on other sites
Guest

Joe

 

In products_info add this code somewhere (top will do):

while ( list( $key, $val ) = each( $HTTP_POST_VARS ) ) {
 if(is_array($HTTP_POST_VARS("$key")) {
   echo $key . '=[]<br>';
 } else {
   echo $key . '=' . $val . '<br>';
 }
}

This will list your post variables after you click 'add to cart'. What you get are entries like:

Qty_ProdId_XX=1
Qty_ProdId_XX=0
id_XX=[]

Where XX is the product id of your slaves. The id_XX=[] are the important ones. There should also be a matching Qty_ProdId_XX for each id_XX. If you find any that don't match up there's a problem.

 

If nothing obvious turns up you could post your 'add_slave' processing in application_top and I'll have a look.

 

Brian.

Share this post


Link to post
Share on other sites

Brian,

I have posted your debug code everyway I can think of in product_info and it only returns a blank page. I have surrounded it with <?php ?> as well. I must be an idiot this morning. What am I doing wrong here? At any rate all the variables appear to be present when mozilla looks at the page info.

 

while ( list( $key, $val ) = each( $HTTP_POST_VARS ) ) {

if(is_array($HTTP_POST_VARS("$key")) {

  echo $key . '=[]<br>';

} else {

  echo $key . '=' . $val . '<br>';

}

}

 

Here is the add_slave section:

 

//Master Products                         

      // customer adds multiple products from the master_listing page 

      case 'add_slave' :     

                              while ( list( $key, $val ) = each( $HTTP_POST_VARS ) ) { 

                                if (substr($key,0,11) == "Qty_ProdId_") { 

                                $prodId = substr($key,11); 

                                $qty = $val; 

                                if ($qty <= 0 ) continue; 

 

                                $cart->add_cart($prodId, $cart->get_quantity(tep_get_uprid($prodId, $HTTP_POST_VARS['id']))+($qty), $HTTP_POST_VARS['id']); 

 

                                } 

                              } 

                              tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); 

                              break; 

      //Master Products EOF                                           

 

One problem I notice is the sort of the Option. I have 3 slaves with 2 attributes. The first row has the option sorted alpha but the next 2 are by id number. Don't know if this has any bearing.

 

 

Thanks for helping. I really want to get your mod working.

 

joe

Share this post


Link to post
Share on other sites

Try using this:

//Master Products
    // customer adds multiple products from the master_listing page
    case 'add_slave' :
                            while ( list( $key, $val ) = each( $HTTP_POST_VARS ) ) {
                              if (substr($key,0,11) == "Qty_ProdId_") {
                                $qty = $val;
                                $prodId = substr($key,11);
                                if(isset($_POST["id_$prodId"]) && is_array($_POST["id_$prodId"])) {
                                  // We have attributes
                                  $cart->add_cart($prodId, $cart->get_quantity(tep_get_uprid($prodId,$_POST["id_$prodId"]))+$qty, $_POST["id_$prodId"]);
                                } else {
                                  // No attributes
                                  $cart->add_cart($prodId, $cart->get_quantity($prodId)+$qty);
                                }
                              }
                            }
                            tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
                            break;
    //Master Products EOF


If I was crafty, this would be a funny signature.

Share this post


Link to post
Share on other sites

DA DAAA!!!

 

That's it. Now working properly.

 

Brian, you da man!

 

Now where do I control the sort order of the option...

 

 

Thanks, Brian

 

 

Joe

Share this post


Link to post
Share on other sites

Ok, here is a question for everyone.

 

I am trying to get the product description of the slave to be added as an attribute so that it will display on all the right pages (ie shopping cart, invoices, order history, etc).

 

I want to do this so that we will know what option they selected so instead of just seeing 16A11A3 for example since the person purchased the third slave, it will also show 3 Dia = .4ct 4 Rubies so that we know which one they bought without having to go look it up.

 

So far I am working on using a hidden field but it is not getting inserted right. I think it has to do with there not being any values in attributes. Anyone got any ideas?


If I was crafty, this would be a funny signature.

Share this post


Link to post
Share on other sites

Joe to sort the options use this at the end of the query in master_listings

order by pa.options_values_price ASC, pov.products_options_values_name DESC

 

It sorts it first by price, then by name. This way the default will be shown first. If there are two values that don't change the priceor change it by the same amount, it will sort them by name.

 

 

Anyone know how to sort the order of the slave products displayed by their base price?

Edited by ryanf

If I was crafty, this would be a funny signature.

Share this post


Link to post
Share on other sites

Thanks Ryan, I think that fixed the sort issue.

 

I have one small "bug."

1064 - You have an error in your SQL syntax near 'limit 0, 20' at line 1

 

select pd.products_description, p.products_weight, pd.products_name, p.products_id, p.manufacturers_id, p.products_tax_class_id, s.specials_new_products_price, s.status, p.products_price from products_description pd, products p left join manufacturers m on p.manufacturers_id = m.manufacturers_id left join specials s on p.products_id = s.products_id where p.products_id = pd.products_id and p.products_master = '34' and p.products_status = '1' and pd.language_id = '1' order by limit 0, 20

 

[TEP STOP]

 

This occurs if the title line of the slave table is clicked for "Sort products ascendingly by options."

Sorting by name, weight and price works fine. I can't really see any reason to sort this field. But I guess it may be "hardwired" in the algorithm.

 

Any suggestions on how to prevent this or how to turn off this particular customer sort capability on the Options field?

 

Ryan, I notice you have zero sorting on your slave table. (the one I looked at.)

 

Thanks

 

joe

Share this post


Link to post
Share on other sites

Yeah I took of sorting, I thought that stupid + sign was annoying and I really didn't think it was a great enough feature to keep in.

 

Now that I actually want it sorted though I might have to put some of it back in, I forgot about the sort code I took out :P

 

I dont really know the answer to your problem though, I would try to figure out whats different or try to take out the sort function on the product options column.

 

Can you post a link to your page? I am curious on how you are setting up slaves and attributes

Edited by ryanf

If I was crafty, this would be a funny signature.

Share this post


Link to post
Share on other sites

Ryan,

 

Heres the page Test Webpage

 

The first application in my case is simply different weights of coffee and then the type of grind the customer may want.

 

The next step to build after this is sample assortments or gift packs where the customer can select e.g. 3 varieties from a possibilty of say 12. How am I going to do that? LOL.

 

And I'll probably get into a "family" of goods like you have done.

 

It was very important for me at this test stage to make sure I could have different sizes and grinds on one page as we have that in our current cart, although not as well laid out as in oscommerce.

 

The help I've gotten here from you and Brian and others has been superb. I'm very pleased to be working in this package. Great community here.

 

 

joe

Share this post


Link to post
Share on other sites
Guest

Ok folks. Looks like the basic slave attribute handling is working fine. I'll give it about a week or so to see if anything else gets shaken out. Then repost the complete instructions to add slave attributes to a base ms2 store with master products. I'll also include the language/admin changes.

 

Hopefully then Matt will merge it into the main contrib.

 

Brian.

Share this post


Link to post
Share on other sites

Joe I think that error is coming from the sql command order by limit.

You have to have something there to order by such as:

order by products_name limit 0, 12

 

Try that.

 

Ryan


If I was crafty, this would be a funny signature.

Share this post


Link to post
Share on other sites

Glitch.

 

In my excitement of Ryan's code suggestion getting the slave attibutes to function I did not realize the regular items with one attribute plus quantity were only writing the qty to the cart and not the attribute.

 

Here is the code in application_top.php:

//Master Products                         

      // customer adds multiple products from the master_listing page

      case 'add_slave' :

                            while ( list( $key, $val ) = each( $HTTP_POST_VARS ) ) {

                              if (substr($key,0,11) == "Qty_ProdId_") {

                                $qty = $val;

                                $prodId = substr($key,11);

                                if(isset($_POST["id_$prodId"]) && is_array($_POST["id_$prodId"])) {

                                  // We have attributes

                                  $cart->add_cart($prodId, $cart->get_quantity(tep_get_uprid($prodId,$_POST["id_$prodId"]))+$qty, $_POST["id_$prodId"]);

                                } else {

                                  // No attributes

                                $cart->add_cart($prodId, $cart->get_quantity($prodId)+$qty);

                                }                             

                              }

                            }

                            tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));

                            break;

      //Master Products EOF                                                     

 

The fix: replace line under // No attributes with:

//No attributes

$cart->add_cart($prodId, $cart->get_quantity(tep_get_uprid($prodId, $HTTP_POST_VARS['id']))+($qty), $HTTP_POST_VARS['id']);

 

Hopefully this will stand up. This line of code was cadged by the way. Probably from Brian.

You may try substituting $HTTP_POST_VARS with $_POST. I need sleep before I try it

 

joe

Share this post


Link to post
Share on other sites

I have certain products that belong in two or more categories. Some of them are slaves. Their master product on the other hand belongs only in one category.

 

Has anyone written a mod to show the hidden slave products belonging to a particular category when their master product doesn't belong to the same category?

Share this post


Link to post
Share on other sites

joe, I think why the regular products with attributes is not working is because they have a call something like id[ while the mods that brian and I have made have a call like id_ try changing the ones in product_info to the same as in master_listings with the id_ and that should work. I think I had to do that also.

 

 

Radders: I think you would almost need another field in the database to keep track of that one.

 

 

Ryan

Edited by ryanf

If I was crafty, this would be a funny signature.

Share this post


Link to post
Share on other sites

When using this contrib, aren't product notifications rendered useless for slave files if they're hidden? Since you can no longer go to these pages, to subscribe? Is it possible to make it so that if a user subscribes for product notification on the master product that it'll also subscribe them to the slave products so if anything changes they'll be notified and pointed back to the master product url?

Share this post


Link to post
Share on other sites
Is it possible to make it so that if a user subscribes for product notification on the master product that it'll also subscribe them to the slave products so if anything changes they'll be notified and pointed back to the master product url?

 

Good idea, I can't see how that would be difficult to implement. I think one would just need to ensure that when any of the slaves are changed, via the osC admin or with one of those mass upload programs, that the master products' products_last_modified field (a date) is updated as well, that should flag it as being updated.

 

...Dono

Edited by Donovan

Share this post


Link to post
Share on other sites

When setting slave products to hidden is there any other places that need to be fixed besides the ones listed below, and would the fixes from 1.1.2 be compatiable

 

manufacturer

whats new

search

new products

quantity select input

shopping_cart

specials

product notification for slaves

reviews

tell a friend

buy now button on master product

products_new

Share this post


Link to post
Share on other sites
Hi - first of all - thanks to Matt!

 

The new version is very good an has good new features - I implemented it and it is like this now:

 

asis.gif

 

I was wondering if it was a big problem to change it around that it works like this:

 

asshouldbe.gif

 

I do I only have to change around in the products_info.php ?

 

 

 

I think it's a little bit more to do - isn't it? - thanks in advance, you do a great job Matt! :huh: :blink:

The select option with the + - quantity is pretty nice! Also what would be cool is if users could input numbers as well and still use the + - quantity.

Share this post


Link to post
Share on other sites
I have certain products that belong in two or more categories. Some of them are slaves. Their master product on the other hand belongs only in one category.

 

Has anyone written a mod to show the hidden slave products belonging to a particular category when their master product doesn't belong to the same category?

I may be missing the point, but if the slaves are products to be sold in their own right, do they need to be hidden? You can stop them showing up in the master product's category by not including them in that category. They will still display under the master product when it is selected.

 

Matt

Share this post


Link to post
Share on other sites

:D I see what you mean. I still want then to show up in the normal way under the master product. I just need them hidden so they don't show up on their own when the master product exists in the same category because it just looks bad and is confusing for the customer.

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

×