Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Nobody Can Figure this one out


rjohnson

Recommended Posts

I posted this 2 times a few weeks ago with no response. Im guessing it can't be done or nobody can figure out how to do it:

 

How can I go about disabling the "add to cart" button on some products. Or maybe have an if/then statement that says if category=category_b not show add to cart button.

 

Thanks in advance

Link to comment
Share on other sites

Is this because you want your product to show up but you don't have any to sell at the time?

 

if so...maybe set the product qty to 0. This comes up with a warning saying you don't have any available to sell.

Link to comment
Share on other sites

No...I want it to show up with the price, but not let them add it to the cart. They need to call in because it's a firearm. They need to go to a dealer and get an FFL.

Basically, I want another button there to say "call" or "call to order"

Then we will do the transfer. I want only the firearms on the site to not have a "add to cart" button but everything else can. What do you think?

Link to comment
Share on other sites

If you can put FIRE or FIREARM at the front of the Product Model you can accomplish your requirement this way.

 

1. Create CALL button and place in catalog/includes/images/english/images/buttons/

 

2. In catalog/includes/languages/english.php

 

Add

 

define('IMAGE_BUTTON_CALL', 'Call'); // Add Call Button Definition

 

 

 

 

3. In catalog/product_info.php

 

Find This:

<td class="main" align="right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART) ?></td>

 

 

And replace it with this:

 

<td class="main" align="right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']);

if (ereg('^FIRE', ($product_info['products_model']))) {

echo tep_image_submit('button_call.gif', IMAGE_BUTTON_CALL);

} else {

echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART);

}

?></td>

while (!succeed) {try()};

 

GMT -6:00

Link to comment
Share on other sites

CORRECTION!!!

 

Sorry I was asleep when I posted this.

 

If you can put FIRE or FIREARM at the front of the Product Model you can accomplish your requirement this way.

 

1. Create CALL button and place in catalog/includes/languages/images/english/images/buttons/

 

2. In catalog/product_info.php

 

Find This:

<td class="main" align="right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART) ?></td>

 

 

And replace it with this:

 

<td class="main" align="right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']);

if (ereg('^FIRE', ($product_info['products_model']))) {

echo '<img src="includes/languages/english/images/buttons/button_call.gif">';

} else {

echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART);

}

?></td>

while (!succeed) {try()};

 

GMT -6:00

Link to comment
Share on other sites

And thanks for that post, I can use that on another section of the site..

That would work great but I can't put anything like "fire" or "firearm" in front of the model.

 

Can you figure out a way to make all products in a certain category not show the button?

 

I have a category called Firearms with all the firearms in it. I want all of those products to display the "call to order" button and not "add to cart"

 

Similar to this but I don't know how to write it correctly:

A part of your code says:

if (ereg('^FIRE', ($product_info['products_model']))) {

 

What about something like this:

if (ereg('^FIRERAMS', ($product_info['products_category']))) {

 

What do you think?

Link to comment
Share on other sites

if ($cPath == "xx") {
? ?echo tep_image('button_call.gif', 'Call for more Information');
} else {
? ?echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART);
}

 

 

Where xx is the category ID for firearms.

Link to comment
Share on other sites

That works great but only if I put in the path to each page of manufacturer.

In the firearms category, I have a few manufacturers, lkie S&W, Glock Beretta etc..

 

Example: Firearms is path=24 (does not work at all)

I put this code in and it works but only for S&W, not any others:

S&W is Path 24_27 so....

 

if ($cPath == "24_27") {

echo '<img src="includes/languages/english/images/buttons/button_call_to_order.gif">';

} else {

echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART);

}

?></td>

 

Glock is path 24_21

 

Is there a way to do this for all the firearms manuacturers that are firearm related. Can I do it like a widcard type of thing like this:

 

if ($cPath == "24*") { (i know that wont work but you get the idea)

 

This way I wont have to keep putting lines of code in every time I add a manufacturer.

 

Thanks for your help, it's got me farther than I was.

If you need the link to this site let me know and I'll email it to you with username and password. email me at [email protected]

 

RJ

Link to comment
Share on other sites

why don't you just add another field to the products_description table called 'firearm' and you can enter a value of 1 if it is, and 0 if it isn't.

 

That way it won't matter what the cPath is or isn't. Then just make your if statement

 

if ($query_results['firearm'] == '0') {

show buy now

} else {

show call button

}

 

It will require you to do a query, but just add the firearm field to the main query on the products_info.php page and you are all set.

 

-Chris

Chris Sullivan

Link to comment
Share on other sites

That would be the absolute best way to do it, but I will probably

not get it right and waste another 10 hrs just on that.

 

If you care to post or email me the right way to do it, I would be greatful.

I am not too bad with figuring php code out, but I am no way considered

a coder.

 

Any help with this one last problem will get me out of a big jam.

 

Thanks so much

 

RJ

Link to comment
Share on other sites

S&W is Path 24_27 so....

if (substr($cPath, 0, 2) == "24") {
  echo '<img src="includes/languages/english/images/buttons/button_call_to_order.gif">';
} else {
  echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART);
}

Link to comment
Share on other sites

switch (substr($cPath, 0, 2)) {
 case "24":
 echo tep_image('button_call_to_order.gif', 'Call to Order');
 break;
 default:
 echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART);
}

 

Is nicer, and more portable, and easier to update in the future if you ever add another Category you do not want to have "buy button" on. As an example, if you had a category "40":

 

switch (substr($cPath, 0, 2)) {
 case "24":
 case "40":
 echo tep_image('button_call_to_order.gif', 'Call to Order');
 break;
 default:
 echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART);
}

 

If you wanted to get rid of lots of cats and subcats, you could do this:

 

switch ($cPath) {
 case "24":
 case "24_1":
 case "24_4":
 case "24_5":
 echo tep_image('button_call_to_order.gif', 'Call to Order');
 break;
 default:
 echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART);
}

 

Which would mean 24, 24_1, 24_4 and 24_5 would all have "call buttons", and every other subcat inside 24 (as well as any that are elsewhere in your shop would have "buy now" button.

 

hth

Link to comment
Share on other sites

I got it to work like this. Thanks to Burt!

 

<td align="right" class="main"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']);

switch (substr($cPath, 0, 2)) {

case "24":

echo tep_image_button('button_call_to_order.gif', IMAGE_BUTTON_CALL_TO_ORDER);

break;

default:

echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART);

}

Link to comment
Share on other sites

  • 4 weeks later...

I shut the buy now button off, but that didn't help much. I had to put a few scripts in a few different pages to only show the call to order button under certain items. Burt, helped me out alot and his code works great. I had a few other pages that would still display the add button, so I added a new varible under the add products page, so now I have total control over when and where the button shows.

 

 

Ray

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...