Announcement

Collapse
No announcement yet.

Minimum order value by country.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Minimum order value by country.

    Loen Paul on the V5 forum wanted a way to alter the minimum order value depending on the Shipping Destination.

    Since I've happily used their fencing equipment for 20 years I made a general purpose solution that is quite flexible. Here it is rejigged for V6:-

    Code:
    Setting a minimum order value by country for Catalog V6.
    
    This will allow you to specify minimum order values for a list of selected countries 
    and a default minimum for countries that are not in that list.  
    You can have a minimum of 0 for a particular country, or for the default minimum.
    
    In the eaxample below we have minimum order value of £10 for United Kingdom,
    £20 for Germany, and £50 for any other country.
    
    Instructions:-
    
    Go to Catalog / Advanced / Custom Properties 
    Click the "+" sign and create a new CustomVar called DEFAULTMINORDER
    Again  click the "+" sign and create a new CustomVar called COUNTRYMINORDER
    Ok out.
    
    Choose Design / Options / Site Defaults.  Look in Properties.
    Select the property DEFAULTMINORDER and set it to whatever you wish you default
    minimum to be in your usual currency.  E.g. 50 for £50.00
    
    Select the property COUNTRYMINORDER and set it to a comma separated list of countries and minumiums
    in the following format.  E.g.   "United Kingdom", 10, "Germany",  20
    
    You must obey this format exactly or you will get a server error on checking out.
    Keep quotes around the country names.  Use numbers ( like 10 or 12.34 )for the amounts.
    The country names need to match those in the list you see when checking out.
    You can have as many pairs of entries as the 256 characters that CUSTOMVAR's allow.
    
    Ok out.
    
    Edit OrderScript.pl (Back it up first. Use a text editor - see www.editpadlite.com if you don't have one).
    
    Search for 
    
    	sub DisplayPaymentPhase
    
    look down some lines 'till you see
    
    	$nTotal = $SummaryResponse[6];
    	#
    	#	1) If (total == 0 || prices are off)
    	#		If (user defined field is hidden)
    	#
    	#			mark payment complete
    	#			mark method pre-pay
    	#			skip processing
    	#
    	#		else If (user defined is not hidden)
    	#
    	#			mark method pre-pay
    	#			hide payment stuff
    	#
    
    
    immediately after this ADD the following code
    
    
    
    	my $nMinOrder = CUSTOMVAR:DEFAULTMINORDER;
    	my %CountryMinOrder = (CUSTOMVAR:COUNTRYMINORDER);
            my $sDelCountry = ACTINIC::GetCountryName($::g_LocationInfo{DELIVERY_COUNTRY_CODE});
    
    	if ( exists $CountryMinOrder{$sDelCountry} )
    		{
    		$nMinOrder = $CountryMinOrder{$sDelCountry};
    		}
    
    	if ( ($nTotal / 100) < $nMinOrder )
                   	{
    		@Response = ActinicOrder::FormatPrice($nMinOrder * 100, $::TRUE, $::g_pCatalogBlob);
    		if ($Response[0] != $::SUCCESS)
    			{
    			return ($::FAILURE, $Response[1]);
    			}
                    return ($::FAILURE, "Minimum order value for " . $sDelCountry . " is " . $Response[2]);
                    }
    
    
    
    Save and update your site and that's that.
    
    You can maintain the countries and minimums by altering the Custom Properties DEFAULTMINORDER and
    COUNTRYMINORDER in Design / Options / Site Defaults.
    It's also attached in case the forum munges the above.

    Norman
    Attached Files
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    #2
    Thanks again Norman for a very useful solution.

    Comment

    Working...
    X