Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

whats worng with this code


Guest

Recommended Posts

I have free shipping per product V1.0 installed (http://addons.oscommerce.com/info/2517) and I’m trying to install V1.1, the problem is I don't want most of the features of v1.1. All I want is the ability to show "FREE SHIPPING!" on the product_listing page (only if free shipping is enabled on the product). I have managed to get "free shipping" displayed on every product but I only want it to be displayed if the product has free shipping enabled. The code I have added to product_listing is:

 

				   case 'PRODUCT_LIST_BUY_NOW':
		$lc_align = 'center';
		if ($listing['products_free_shipping'] = "true") {
		  $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> <br><br><b>' . FREE_SHIPPING_FOR_THIS_PRODUCT . '</b> ';
		} else {
		  $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';
		}
		break;
	}

 

the code above displays "free shipping!" under the buy it now button on every product, even for products that don't qualify for free shipping (not good). I only want it to display if the product has free shipping enabled. What am I doing wrong?

 

Thanks.

Link to comment
Share on other sites

You are declaring it true instead of evaluating if is true. This should work better (perhaps leaving out the quotes around true?):

if ($listing['products_free_shipping'] == "true") {

 

 

Many thanks for the suggestion, unfortunatly it didin't solve the issue.

 

if ($listing['products_free_shipping'] == "true") {

 

Didn't work.

 

if ($listing['products_free_shipping'] == true) {

 

also didn't work. Neither caused any error messages, just didn't display free shipping next to any products on product_listing.

 

I know nothing about php etc but I have noticed that the only reference in the database regarding free shipping is this:

 

ALTER TABLE `products` ADD `products_free_shipping` TINYINT( 1 ) DEFAULT '0' NOT NULL;

Link to comment
Share on other sites

Many thanks for the suggestion, unfortunatly it didin't solve the issue.

Judging from the sql you used to add this option to the database it should have been either

if ($listing['products_free_shipping'] == "1") {

or

if ($listing['products_free_shipping'] == 1) {

or

if ($listing['products_free_shipping'] == true) {

 

The fact that it doesn't give the desired result doesn't mean the code is wrong. You might have forgotten to add the field products_free_shipping to the queries in index.php.

 

You can perhaps check that also by outputting the $listing in includes/modules/product_listing.php (I assume). Probably somewhere after:

while $listing = tep_db_fetch_array(...

add:

echo '<pre>Listing: <br />';
print_r($listing);
echo '</pre>';

You might find that you don't see products_free_shipping in there.

Link to comment
Share on other sites

You might have forgotten to add the field products_free_shipping to the queries in index.php.

 

That was the problem, I didn't add the four "p.products_free_shipping" in index.php . Works flawlessly now, I am one happy bunny :) .

 

Thanks for all your help Jan, I really do appreciate it. I wish I could get my head around php code and help others on the forum instead of just asking for help myself.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...