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.

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, frankmullenger, biapar, Willr, Ingo, Jedateach, swaiba, simon_w

TotalDeliveryModifier help needed


Reply

2 Posts   377 Views

Avatar
Zyzzza

17 October 2011 at 5:45am Community Member, 25 Posts

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
Zyzzza

18 October 2011 at 6:26am Community Member, 25 Posts

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"; }

      
    }

   

}