Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

E-Commerce Modules /

Discuss about the various e-commerce modules available:
Ecommerce, SS Shop, SilverCart and SwipeStripe
Alternatively, have a look the shared mailinglist.

Moderators: martimiz, Nicolaas, Sean, Ed, frankmullenger, biapar, Willr, Ingo, Jedateach, swaiba

TotalDeliveryModifier help needed


Go to End


2 Posts   936 Views

Avatar
BP

Community Member, 25 Posts

17 October 2011 at 5:45am

Hi,

I'm testing 0.8.2 rc1 and need to create a modifier for adding shipping price if TOTAL is less then 100USD, and would charge 5USD delivery charge if TOTAL is less then 100USD.

Maybe anyone post a solution here, as I'm not really familiar with modifiersand not surte how to store all that in Database and on invoices :(

cheers

Avatar
BP

Community Member, 25 Posts

18 October 2011 at 6:26am

OK, solved that (in fact I've solved almost all my questions i've asked on forum myself :) )

So, just in case someone comes here for the same task , below is the code for the modifier (as usuall - you have to enable it in _config.php, build DB , and then tweak some SS files to ensure it shows up on receipts and reports)

<?php

class PriceShippingModifier extends OrderModifier {

	function LiveAmount() {
		
		$order = $this->Order();
		$total = $order->SubTotal();
		
                 //If total is more than 200 than delivery is free, otherwise - charge 5 bux

		if ($total<=200){ return 5; }
		else { return 0; }
			
	 }
	 
	 function CartTitle() {
		$order = $this->Order();
		$total = $order->SubTotal();
		
 		if ($total<=200){ return "Delivery"; }
		else { return "Free Delivery"; }

	 }


	 function TableTitle() {
		$order = $this->Order();
		$total = $order->SubTotal();
		
 		if ($total<=200){ return "Delivery"; }
		else { return "Free delivery"; }

		
	 }


	

}