[ic] Patch to differentiate between free shipping and unavailable shipping methods

Stefan Hornburg racke at linuxia.de
Wed May 27 11:38:00 UTC 2009


Mark Lipscombe wrote:
> Hi,
> 
> Here is a small patch which lets Vend::Ship::shipping return undefined 
> when a cost cannot be calculated for shipping.  This allows ITL code 
> like this:
> 
> [either][shipping][or]Not enough info[/either]
> 
> This allows you to have free shipping options, but not show them if a 
> shipping calculation cannot be done (for example if that shipping method 
> isn't available to that location).
> 
> It applies cleanly against CVS HEAD, and also applies with fuzz to 5.4 
> and 5.6 versions of IC.
> 
> Regards,
> Mark
> 
> 
> ------------------------------------------------------------------------
> 
> Index: lib/Vend/Ship.pm
> ===================================================================
> RCS file: /var/cvs/interchange/lib/Vend/Ship.pm,v
> retrieving revision 2.29
> diff -u -r2.29 Ship.pm
> --- lib/Vend/Ship.pm	5 Nov 2008 22:38:52 -0000	2.29
> +++ lib/Vend/Ship.pm	16 May 2009 23:35:07 -0000
> @@ -774,6 +774,8 @@
>  				logError($error_message);
>  				last SHIPIT;
>  			}
> +			last SHIPIT unless defined $cost;
> +			last SHIPIT unless ($cost == 0 or $cost > 0);

Objection one: this is same as $cost >= 0

>  			$final += $cost;
>  			last SHIPIT unless $o->{continue};
>  		}
> @@ -914,6 +916,10 @@
>  				$final = $final > $o->{at_least} ? $final : $o->{at_least};
>  			}
>  		}
> +		#if($final == undef) {
> +#::logDebug("XXX undef");
> +#			return '';
> +#		}
>  		if($opt->{default}) {
>  			if(! $opt->{handling}) {
>  				$::Values->{mv_shipmode} = $mode;
> @@ -1090,13 +1096,16 @@
>  		unless (defined $out) {
>  			$out = 0;
>  			for(@modes) {
> -				$out += shipping($_, $opt) || 0;
> +				my $m = shipping($_, $opt);
> +				$out = $m;
>  			}

Objection two: this takes away cumulative calculation and also $m is
superfluous.

Regards
	Racke

-- 
LinuXia Systems => http://www.linuxia.de/
Expert Interchange Consulting and System Administration
ICDEVGROUP => http://www.icdevgroup.org/
Interchange Development Team




More information about the interchange-users mailing list