Post by mchaggis » Sat Jun 20, 2009 7:29 am

Alright, I have some programming experience but virtually none with PHP, other than what I've picked up playing with opencart. I want to change my flat rate shipping module into a percentage based module with a minimum. This doesnt seem like it should be too terribly hard to accomplish. From what I can see poking around flat.php, it gets the cost here:

Code: Select all

'cost'         => $this->config->get('flat_cost'),
so I'm thinking change it to something like

Code: Select all

'cost'         => $with_percent,
and define the $with_percent variable something like this

Code: Select all

if ( $sub_total <= 70 ) {
	$with_percent = 10
} else {
	$with_percent = $sub_total * .15
}
so that if the order is under 70 bucks, it charges ten dollars shipping, if it's above, it charges 15%.
problems:
- i'm sure this syntax is nothing close to right
- not entirely sure how to access $sub_total
Any help turning this thought-dump into usable code would be much appreciated.

"to trifle away their time, scald their Chops, and spend their Money, all for a little base, black, thick, nasty, bitter, stinking, nauseous Puddle-water"


User avatar
Newbie

Posts

Joined
Thu Jun 11, 2009 3:05 am

Post by Qphoria » Sat Jun 20, 2009 8:05 am

mchaggis wrote:

Code: Select all

if ( $sub_total <= 70 ) {
	$with_percent = 10
} else {
	$with_percent = $sub_total * .15
}
You're pretty close.

Try:

Code: Select all

$sub_total = $this->cart->getSubtotal();
if ( $sub_total <= 70 ) {
	$with_percent = 10;
} else {
	$with_percent = $sub_total * .15;
}

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Qphoria » Sat Jun 20, 2009 10:20 am

You also might be interested in my zone shipping plus module that supports subtotal, weight, and itemcount calculations. And static amounts as well as percentages for the cost.
http://forum.opencart.com/viewtopic.php?f=13&t=4502

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am
Who is online

Users browsing this forum: Bing [Bot] and 9 guests