Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

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

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #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
  #2  
Old 09-21-2005, 06:05 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default

NICE!!!!!
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #3  
Old 09-06-2006, 10:57 AM
 
magazine-collector magazine-collector is offline
 

Newbie
  
Join Date: Aug 2006
Posts: 6
 

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

Hi,

Totally new user here, and probably ranking near the very bottom of this group when it comes to being tech-savvy! That said, I've been setting up my cart myself relying heavily on the manual and these boards, and could really use the solution proposed here...but am confused!

First off, since this topic is almost a year old, is this solution still working and/or is there a different/better option that has cropped up? Would especially love to hear from the original poster or balinor (whose name I've come across so often here!)

I'm assuming this is a solution where I could specify, for example, a 3-5 pound rate for Media Mail in conjunction with a 0-5 pound rate for Priority with the result for the customer being, again for example, a 0.0-2.9 lb. order shows only Priority option w/Media option invisible and anything 3 lbs and over would show both Media and Priority Rates. Whereas by default a package less than 3 lbs that I did not want to offer the Media rate on would still show the customer the cheaper/unavailable rate? Correct?

I'm using X-Cart 4.0.18, which I assume is very similar to 4.0.15 that the original poster implemented this on. Has anyone tried with success on 4.0.18?

I can locate where to make the 2nd change (in admin/shipping.php) and the fourth change (in skin1/admin/main/shipping.tpl), but have no clue where to make the change to includes/shipping.php (I have a file called just include, w/o the "s" but there is no shipping.php file under it?) and do not understand where to make the first change (Add a new row to the shipping table like this...) -- not sure where I add code to the shipping table?

Thanks in advance!

Cliff Aliperti
X-cart 4.0.18
__________________
Cliff Aliperti
X-Cart Gold 4.0.18
Reply With Quote
  #4  
Old 09-13-2006, 06:45 AM
 
salsabeel salsabeel is offline
 

Senior Member
  
Join Date: Jan 2004
Posts: 132
 

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

Quote:
Originally Posted by magazine-collector
Hi,

Totally new user here, and probably ranking near the very bottom of this group when it comes to being tech-savvy! That said, I've been setting up my cart myself relying heavily on the manual and these boards, and could really use the solution proposed here...but am confused!

First off, since this topic is almost a year old, is this solution still working and/or is there a different/better option that has cropped up? Would especially love to hear from the original poster or balinor (whose name I've come across so often here!)

I'm assuming this is a solution where I could specify, for example, a 3-5 pound rate for Media Mail in conjunction with a 0-5 pound rate for Priority with the result for the customer being, again for example, a 0.0-2.9 lb. order shows only Priority option w/Media option invisible and anything 3 lbs and over would show both Media and Priority Rates. Whereas by default a package less than 3 lbs that I did not want to offer the Media rate on would still show the customer the cheaper/unavailable rate? Correct?

I'm using X-Cart 4.0.18, which I assume is very similar to 4.0.15 that the original poster implemented this on. Has anyone tried with success on 4.0.18?

I can locate where to make the 2nd change (in admin/shipping.php) and the fourth change (in skin1/admin/main/shipping.tpl), but have no clue where to make the change to includes/shipping.php (I have a file called just include, w/o the "s" but there is no shipping.php file under it?) and do not understand where to make the first change (Add a new row to the shipping table like this...) -- not sure where I add code to the shipping table?

Thanks in advance!

Cliff Aliperti
X-cart 4.0.18
you can apllay changeing in
shipping/shipping.php

in 4.0.18
When I apply that changes in shipping/shipping.php
no shipping method is appeared with any weight
Code:
Sorry, there are no available shipping methods for your location
This message appeared because new code not contain
Code:
weight_limit='0'
because in all method in my store weight_limit=0
I solve this problem by this
- with the method that I want begin from specific weight I put min value and max value of weight
- change the code in shipping/shipping.php
From
Code:
# # The preparing to search the allowable shipping methods # $weight_condition = " AND (weight_limit='0' OR weight_limit>='$total_weight_shipping')";
To
Code:
# # The preparing to search the allowable shipping methods # $weight_condition = " AND (weight_limit='0' OR '$total_weight_shipping'<=weight_limit AND '$total_weight_shipping'>=weight_limit_min )";

It's work good with me now

Thanks Mr. shan
__________________
X-Cart Platinum 4.6.5
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 08:51 AM.

   

 
X-Cart forums © 2001-2020