View Single Post
  #1  
Old 09-21-2005, 05:51 AM
  shan's Avatar 
shan shan is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Birmingham, UK
Posts: 6,163
 

Default Shipping With MIN & MAX weight options - V4.0.x

Heres a mod that will allow you to enter not only the maximum weight limit for a user defined shipping method but also the minumum weight to trigger the availablity of the shipping method.

This has not been tested or coded to deal with real time shipping methods. Saying that its not been fully tested at all so use this as a guide or a starting point. It seems to work ok so far with V4.0.15 that it was done in

Basic example is

Method 1 - Courier 1 : Packages up to 100Kg - бё10
Method 2 - Courier 2 : packages Over 100kg - бё20

At the moment if you do this then both couriers and prices show in the shipping options drop down. Customer will no doubt not choose a more expensive courier but it could cause confusion. What we want is that only the couriers that we choose are displayed.

All Ive done is add another field to the shipping table for MIN weight

Add a new row to the shipping table like this

Code:
ALTER TABLE `xcart_shipping` ADD `weight_limit_min` DECIMAL( 12, 2 ) DEFAULT '0.00' NOT NULL AFTER `weight_limit` ;

Edit admin/shipping.php

replace

Code:
# # Add new shipping method # db_query("INSERT INTO $sql_tbl[shipping] (shipping, shipping_time, destination, orderby, weight_limit) VALUES ('$shipping_new','$shipping_time_new','$destination_new','$orderby_new','$shipping_weight_limit_new')"); }

with

Code:
# # Add new shipping method # db_query("INSERT INTO $sql_tbl[shipping] (shipping, shipping_time, destination, orderby, weight_limit, weight_limit_min) VALUES ('$shipping_new','$shipping_time_new','$destination_new','$orderby_new','$shipping_weight_limit_new','$shipping_weight_limit_min_new')"); }

Edit includes/shipping.php

Replace

Code:
# # The preparing to search the allowable shipping methods # $weight_condition = " AND (weight_limit='0' OR weight_limit>='$total_weight_shipping')";

With

Code:
# # The preparing to search the allowable shipping methods # $weight_condition = " AND ('$total_weight_shipping'<=weight_limit AND '$total_weight_shipping'>=weight_limit_min )";

Edit skin1/admin/main/shipping.tpl

replace it with this
Code:
{* $Id: shipping.tpl,v 1.26.2.5 2005/07/27 13:50:43 max Exp $ *} {include file="page_title.tpl" title=$lng.lbl_shipping_methods} {include file="dialog_tools.tpl"} {$lng.txt_shipping_methods_top_text} {capture name=dialog} <TABLE border="0" cellpadding="2" cellspacing="1" width="100%"> <FORM action="shipping.php" method="POST" name="shippingmethodsform"> <INPUT type="hidden" name="carrier" value="{$carrier}"> <TR> <TD colspan="2"><A name="rt"/>{include file="main/subheader.tpl" title=$lng.lbl_realtime_shipping_methods}</TD> </TR> {section name=car loop=$carriers} <TR class="TableSubHead"> <TD colspan="2"> <TABLE border="0" cellpadding="1" cellspacing="0" width="100%"> <TR> <TD width="25%">{if $carriers[car].code eq $carrier}[img]{$ImagesDir}/darrow.gif[/img]{$carriers[car].shipping}{else}[img]{$ImagesDir}/rarrow.gif[/img]{$carriers[car].shipping}{/if}</TD> <TD width="40%">{$lng.lbl_X_from_Y_shipping_methods_enabled|substitute:"enabled":$carriers[car].total_enabled:"methods":$carriers[car].total_methods}</TD> <TD> {if $config.Shipping.realtime_shipping eq "Y" and $config.Shipping.use_intershipper ne "Y" and $active_modules.UPS_OnLineTools eq "" and ($carriers[car].code eq "CPC" or $carriers[car].code eq "FDX" or $carriers[car].code eq "USPS" or $carriers[car].code eq "ARB")} {$lng.lbl_options} &gt;&gt; {elseif $config.Shipping.realtime_shipping eq "Y" and $active_modules.UPS_OnLine_Tools and $config.Shipping.use_intershipper ne "Y" and $carriers[car].code eq "UPS"} {$lng.lbl_ups_online_tools_configure} &gt;&gt; {/if} </TD> </TR> </TABLE> </TD> </TR> {if $carriers[car].code eq $carrier} <SCRIPT type="text/javascript" language="JavaScript 1.2"> <!-- checkboxes_form = 'shippingmethodsform'; checkboxes = new Array({foreach from=$shipping item=v key=k}{if $k > 0},{/if}'{if $v.code eq $carriers[car].code}active-{$v.shippingid}{/if}'{/foreach}); --> </SCRIPT> {include file="change_all_checkboxes.tpl"} <TR> <TD width="10"></TD> <TD> <DIV align="right" style="line-height:170%">{$lng.lbl_check_all} / {$lng.lbl_uncheck_all}</DIV> <TABLE border="0" cellpadding="2" cellspacing="1" width="100%"> <TR style="BACKGROUND-COLOR: #CCCCCC; HEIGHT: 20px;"> <TD>{$lng.lbl_shipping_method}</TD> <TD>{$lng.lbl_period}</TD> <TD>{$lng.lbl_destination}</TD> <TD nowrap>weight min ({$config.General.weight_symbol})</TD> <TD nowrap>{$lng.lbl_weight_limit} ({$config.General.weight_symbol})</TD> <TD>{$lng.lbl_pos}</TD> <TD>{$lng.lbl_active}</TD> </TR> {section name=prod_num loop=$shipping} {if $shipping[prod_num].code eq $carriers[car].code} <TR{cycle values=", class='TableSubHead'"}> <TD>{$shipping[prod_num].shipping|trademark:$insert_trademark}</TD> <TD><INPUT type="text" name="shipping_time-{$shipping[prod_num].shippingid}" size="8" value="{$shipping[prod_num].shipping_time}"></TD> <TD> {if $shipping[prod_num].destination eq "L"}{$lng.lbl_national}{else}{$lng.lbl_international}{/if} </TD> <TD align="center"><INPUT type="text" size="8" name="weight_limit_min-{$shipping[prod_num].shippingid}" value="{$shipping[prod_num].weight_limit_min}"></TD> <TD align="center"><INPUT type="text" size="8" name="weight_limit-{$shipping[prod_num].shippingid}" value="{$shipping[prod_num].weight_limit}"></TD> <TD align="center"><INPUT type="text" name="orderby-{$shipping[prod_num].shippingid}" size="4" value="{$shipping[prod_num].orderby}"></TD> <TD align="center"> <INPUT type="checkbox" name="active-{$shipping[prod_num].shippingid}" {if $shipping[prod_num].active eq "Y"}checked{/if}> </TD> </TR> {/if} {/section} </TABLE> </TD> </TD> {/if} {/section} <TR> <TD colspan="2"> {include file="main/subheader.tpl" title=$lng.lbl_defined_shipping_methods}</TD> </TR> <TR> <TD colspan="2"> <TABLE border="0" cellpadding="2" cellspacing="1" width="100%"> <TR class="TableHead"> <TD>{$lng.lbl_shipping_method}</TD> <TD>{$lng.lbl_period}</TD> <TD>{$lng.lbl_destination}</TD> <TD>weight min ({$config.General.weight_symbol})</TD> <TD>{$lng.lbl_weight_limit} ({$config.General.weight_symbol})</TD> <TD>{$lng.lbl_pos}</TD> <TD>{$lng.lbl_active}</TD> </TR> {section name=prod_num loop=$shipping} {if $shipping[prod_num].code eq ""} <TR> <TD><INPUT type="text" name="shipping-{$shipping[prod_num].shippingid}" size="32" value="{$shipping[prod_num].shipping}"></TD> <TD><INPUT type="text" name="shipping_time-{$shipping[prod_num].shippingid}" size="8" value="{$shipping[prod_num].shipping_time}"></TD> <TD> <SELECT name="destination-{$shipping[prod_num].shippingid}"> <OPTION value="I" {if $shipping[prod_num].destination eq "I"}selected{/if}>{$lng.lbl_international}</OPTION> <OPTION value="L" {if $shipping[prod_num].destination eq "L"}selected{/if}>{$lng.lbl_national}</OPTION> </SELECT></TD> <TD><INPUT type="text" size="8" name="weight_limit_min-{$shipping[prod_num].shippingid}" value="{$shipping[prod_num].weight_limit_min}"></TD> <TD><INPUT type="text" size="8" name="weight_limit-{$shipping[prod_num].shippingid}" value="{$shipping[prod_num].weight_limit}"></TD> <TD><INPUT type="text" name="orderby-{$shipping[prod_num].shippingid}" size="4" value="{$shipping[prod_num].orderby}"></TD> <TD nowrap> <INPUT type="checkbox" name="active-{$shipping[prod_num].shippingid}"{if $shipping[prod_num].active eq "Y"} checked{/if}> <INPUT type="button" value="{$lng.lbl_delete}" onClick="self.location='shipping.php?mode=delete&shippingid={$shipping[prod_num].shippingid}'"></TD> </TR> {/if} {/section} <TR> <TD class="AdminTitle" colspan="7"> {$lng.lbl_add_shipping_method}</TD> </TR> <TR> <TD><INPUT type="text" name="shipping_new" size="32"></TD> <TD><INPUT type="text" name="shipping_time_new" size="8"></TD> <TD> <SELECT name="destination_new"> <OPTION value="I">{$lng.lbl_international}</OPTION> <OPTION value="L">{$lng.lbl_national}</OPTION> </SELECT></TD> <TD><INPUT type="text" name="shipping_weight_limit_min_new" size="8"></TD> <TD><INPUT type="text" name="shipping_weight_limit_new" size="8"></TD> <TD><INPUT type="text" name="orderby_new" size="4"></TD> <TD></TD> </TR> </TABLE> </TD> </TR> <TR> <TD colspan="6"> <INPUT type="submit" value="{$lng.lbl_update}"></TD> </TR> {if $shipping} <TR> <TD colspan="6" align="right"><INPUT type="button" onclick="self.location='shipping.php?mode=enable_all&carrier={$carrier}'" value="{$lng.lbl_enable_all}"> <INPUT type="button" onclick="self.location='shipping.php?mode=disable_all&carrier={$carrier}'" value="{$lng.lbl_disable_all}"> </TD> </TR> {/if} </FORM> </TABLE> {/capture} {include file="dialog.tpl" title=$lng.lbl_shipping_methods content=$smarty.capture.dialog extra="width=100%"}

All that happened in that file was to add the form fields for the min value too.

Now add a minimum and maximum value in the weight sections of the shipping methods page in the admin area and test it all out

Im sure this could be and may have to be tweaked to work for more complex shipping setups but with basic user defined methods it seems to work ok so far.

Feel free to add to this as you see fit
__________________
Looking for a reliable X-cart host ?
You wont go wrong with either of these.

EWD Hosting
Hands On Hosting
Reply With Quote