Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Sign in to follow this  
mrgreg444

How to disable shipping module if item is 'bulky'

Recommended Posts

Hi All,

 

I am currently looking to upgrade some of our existing table modules. They will not be shown to customers in checkout if any product that has been deemed as 'bulky' is added to the cart.

 

'bulky' is a field that has been added to the products table and is represented by 0 or 1.

 

So far, the only additional code I have is the following, but I'm lacking the knowlege to link $bulky to products.bulky based on the products in the shopping cart.

 

if ( ($this->enabled == true) && ($bulky = 1) ) {

$this->enabled = false;

return;

}

 

Any help would be appreciated.

 

Cheers

Share this post


Link to post
Share on other sites

If I understand you correctly you trying to restrict the delivery options for bulky items, for example you send items by post and by carrier, and the bulky items will only go by carrier, so when someone chooses a bulky item they are not given the option for delivery by post.

 

If that's the case you could use Restrict Delivery - despite what fat_dog says this module does work, though he is right about the documentation.

 

I had to play around with a couple of things to make it work, I will dig out what I changed and post it up here for you

Share this post


Link to post
Share on other sites

I have made a lot of changes to my store, so the code my not be exactly the same. Off the top of my head, the mods that might affect the code are QPBPP, Product Quick Edit, Ultra Pics, Bundled Products, No Default Shipping Method & UK Postcode based carrier shipping, these have all been tweaked to make the site work the way we wanted, so again the code may not be exactly as released.

 

My thanks to all those that developed the above mods

 

 

 

First, BACKUP BACKUP BACKUP !

 

Follow the install instructions but do not update the database just yet (see further down), in the mod I made the following changes:

 

 

\catalog\checkout_shipping.php

 

 

on/about line 400 change to:

<tr valign="middle"><td align="center" class="productInfo">If no shipping rates are available please check your postcode or contact us</td></tr>

 

on line 336 change:

if ($order->restrict_delivery == false || in_array($quotes[$i]['methods'][$j]['title'], $restrict_delivery_allowed) ) {

 

to:

if ($order->restrict_delivery == false || [color=#ff0000]![/color]in_array($quotes[$i]['module'], $restrict_delivery_allowed) ) {

 

on line 341 change:

$checked = (($quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'] == $shipping['id'] || ($order->restrict_delivery == true && $quotes[$i]['methods'][$j]['title'] == $restrict_delivery_allowed[0])) ? true : false);

 

to:

$checked = (($quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'] == $shipping['id'] || ($order->restrict_delivery == true && !$quotes[$i]['module'] == $restrict_delivery_allowed[0])) ? true : false);

 

 

What does this do ?

 

Basically the mod looks for the 'title' however this is wrong for my shipping modules, as this line is dynamic showing the shipping weight, so I want it to change it to look for the module name instead.

I also want also the to make the mod check for files NOT in the list, this made it easier to eliminate the forms of shipping rather than allowing them (to leave this in it's original form leave out the ! in the line 336)

 

 

The sql also needs to be changed:

 

# Insert configuration key for Restrict Delivery shipping method
INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, use_function, set_function) VALUES ('Restrict Delivery shipping method', 'RESTRICT_DELIVERY_SHIPPING_METHOD', 'Interlink', 'Enter the module name(s) for shipping methods not allowed for restricted poducts seperated by ";". The module name is the bold title that appears in the shipping list', 7, 1, now(), NULL, NULL);

#Add boolean field to Products table.  Default value is 0, or "not restricted".
alter table products
add column products_restrict_delivery tinyint(4) not null default 0;

 

 

 

The following section adds a 'Restrict Shipping' field to the Edit Product page in admin to allow easy assignment to a product

 

\catalog\admin\categories.php

 

line 326 insert:

 'products_restrict_delivery' => tep_db_prepare_input($HTTP_POST_VARS['products_restrict_delivery']),

 

lines 529, 539, 855, 1037 insert:

 products_restrict_delivery, 

after

  products_unit,

 

 

line 539 insert:

  , '" . $product['products_restrict_delivery'] . "'

after

 , '" . $product['products_unit'] . "'

 

line 842 insert:

  'products_restrict_delivery' => '',

 

line 1337 after:

<!-- EOF QPBPP -->
		<td class="main"><?php echo TEXT_PRODUCTS_WEIGHT; ?></td>
		<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_weight', $pInfo->products_weight); ?></td>
	  </tr>

 

add:

	   <tr>
		  <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
		</tr>
	  <tr>
		<td class="main">Resticted Shipping (1 for YES 0 for NO)</td>
		<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_restrict_delivery', $pInfo->products_restrict_delivery); ?></td>
	  </tr>

 

 

 

 

 

 

If Product Quick Edit mod is installed

 

 

\catalog\admin\product_quickedit_info.php

 

line 50 insert:

 p.products_restrict_delivery,

before

p.products_unit, 

 

line 61 insert (between the weight & unit lines:

'products_restrict_delivery' => tep_db_prepare_input($HTTP_POST_VARS['products_restrict_delivery']),

 

Line 359 after:

	  <tr>
		<td class="main"><?php echo TEXT_PRODUCTS_WEIGHT; ?></td>
		<td class="main" colspan="3"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_weight', $pInfo->products_weight); ?></td>
	  </tr>

 

insert:

<tr>
		<td colspan="4"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
	  </tr>
	  <tr>
		<td class="main">Restrict Delivery<br>(1 = YES, 0 = No):</td>
		<td class="main" colspan="3"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_restrict_delivery', $pInfo->products_restrict_delivery); ?></td>
	  </tr>

 

 

\catalog\admin\product_quickedit.php

 

 

line 23 after the weight entry add:

 p.products_restrict_delivery,

 

 

change code at lines 70-82 to read:

<tr class="dataTableHeadingRow">
<td class="dataTableHeadingContent" width="8%">Model</td>
<td class="dataTableHeadingContent" width="8%">ID</td>
<td class="dataTableHeadingContent" width="40%">Name</td>
<td class="dataTableHeadingContent" width="2%"> </td>
<td class="dataTableHeadingContent" align="right"width="8%">Price</td>
<td class="dataTableHeadingContent" align="right"width="8%">Stock</td>
<td class="dataTableHeadingContent" align="right"width="8%">Weight</td>
<td class="dataTableHeadingContent" align="right"width="8%">limited</td>
<td class="dataTableHeadingContent" align="right"width="8%">Edit</td>
<td class="dataTableHeadingContent" align="right"width="2%"> </td>
</tr>

 

 

around lines 99-121 change the code to look like this:

echo '<tr valign="middle"' . ($pID == $product['products_id'] ? 'bgcolor="#9999ff"' : (((int)($i/2)*2) == $i ? 'bgcolor="#DFE4F4"' : '')) . '>';
?>
<td width="8%" class="dataTableContent"><?php echo $product['products_model'];?></td>
<td width="8%" class="dataTableContent"><?php echo $product['products_id'];?></td>
<?php echo '<td  width="40%" class="dataTableContent">' . '<b><a href="' . tep_href_link('product_quickedit_info.php', 'action=preview&read=only&pID=' . $product['products_id'] . '&prod_search=' . $prod_search) . '">' .  $product['products_name'] . '</b>' . ($short ? '<br>' . $product['short_desc'] : '') . '</a>'; ?></td>
<td width="2%"> </td>
<td width="8%" class="dataTableContent" align="right"><?phpecho $currencies->display_price($product['products_price'], tep_get_tax_rate($product['products_tax_class_id'])) ; ?></td>
<td width="8%" class="dataTableContent" align="right"><?phpecho $product['products_quantity']; ?></td>
<td width="8%" class="dataTableContent" align="right"><?phpecho $product['products_weight']; ?></td>
<td width="8%" class="dataTableContent" align="right"><?php if ($product['products_restrict_delivery']) echo 'YES'; ?></td>
<td width="8%" class="dataTableContent" align="right"><?php
// BOF Quick Attributes
echo '<a href="' . tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES_QUICK, 'pID=' . $product['products_id'].'&cPath='.$cPath, 'NONSSL') . '" target="_blank">' . tep_image(DIR_WS_IMAGES . 'icon_quick_attribute.png', IMAGE_ICON_QUICK_ATTRIBUTE) . '</a>';
// EOF Quick Attributes
?>
<a href="<?php echo tep_href_link('product_quickedit_info.php', 'action=edit&pID='. $product['products_id'] .'&prod_search=' . $prod_search) ?>">Edit</a></td>
<td width="2%" class="dataTableContent" align="right"> </td>
</tr>
<?php
}
}
?>

 

 

The above is taken from the notes of changes I make to our site, I hope they are accurate enough to help you, but I cannot guarantee they are 100% as they were made a few years ago

Share this post


Link to post
Share on other sites

I'm looking for a similar solution, so I started to install the Restricted Delivery addon mentioned here. However, I quickly learned that this addon is for OSC 2.2 and I'm using OSC 2.3 instead! (SIGH!)

 

Is anyone aware of an addon with this kind of functionality that works with OSC 2.3?

 

Thanks for any and all help provided!

 

Happy New Year!

 

Regards,Chris

Edited by Chrison

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
Sign in to follow this  

×