function setUp() { parent::setUp(); EcommerceTest::setConfiguration(); Order::set_modifiers(array("FlatTaxModifer"), true); FlatTaxModifier::set_tax(0.15, "GST", true); $this->objFromFixture('Product', 'mp3player')->publish('Stage', 'Live'); ShoppingCart::clear(); }
public function testExclusiveTax() { FlatTaxModifier::config()->exclusive = true; $this->cart->clear(); $this->cart->add($this->mp3player); $order = $this->cart->current(); $order->calculate(); $modifier = $order->Modifiers()->filter('ClassName', 'FlatTaxModifier')->first(); $this->assertEquals(30, $modifier->Amount); $this->assertEquals(230, $order->GrandTotal()); }
public function setUp() { parent::setUp(); ShopTest::setConfiguration(); Order::config()->modifiers = array("FlatTaxModifier"); FlatTaxModifier::config()->rate = 0.25; FlatTaxModifier::config()->name = "GST"; $this->mp3player = $this->objFromFixture('Product', 'mp3player'); $this->socks = $this->objFromFixture('Product', 'socks'); $this->mp3player->publish('Stage', 'Live'); $this->socks->publish('Stage', 'Live'); }
static function set_tax($rate, $name = null, $exclusive = true) { self::$rate = $rate; self::$name = (string) $name; self::$exclusive = (bool) $exclusive; }
protected function orderTax_45() { $explanation = "\r\n\t\t\t<h1>45. Order Added Tax</h1>\r\n\t\t\t<p>Move the tax in the order to its own modifier.</p>\r\n\t\t"; if ($this->retrieveInfoOnly) { return $explanation; } else { echo $explanation; } if ($this->hasTableAndField("Order", "AddedTax")) { $this->DBAlterationMessageNow("Moving Order.AddedTax to Modifier.", "created"); $orders = Order::get()->where("\"AddedTax\" > 0")->limit($this->limit, $this->start); if ($orders->count()) { foreach ($orders as $order) { $id = $order->ID; $hasShippingCost = DB::query("SELECT \"AddedTax\" FROM \"Order\" WHERE \"ID\" = '{$id}'")->value(); $addedTax = DB::query("SELECT \"AddedTax\" FROM \"Order\" WHERE \"ID\" = '{$id}'")->value(); if ($addedTax != null && $addedTax > 0) { $modifier1 = new FlatTaxModifier(); $modifier1->CalculatedTotal = $addedTax < 0 ? abs($addedTax) : $addedTax; $modifier1->TableValue = $addedTax < 0 ? abs($addedTax) : $addedTax; $modifier1->OrderID = $id; $modifier1->TableTitle = 'Tax'; $modifier1->write(); $this->DBAlterationMessageNow(" ------------- Added tax.", "created"); } else { $this->DBAlterationMessageNow(" ------------- No need to add tax even though field is present"); } } return $this->start + $this->limit; } else { $this->DBAlterationMessageNow("There are no orders with a AddedTax field greater than zero."); } $this->makeFieldObsolete("Order", "AddedTax"); } else { $this->DBAlterationMessageNow("No need to update taxes."); } return 0; }
OrderManipulation::set_allow_paying(); //shows a payment form // * * * PRODUCTS ProductsAndGroupsModelAdmin::set_managed_models(array("Product", "ProductGroup", "ProductVariation")); Product_Image::set_thumbnail_size(140, 100); Product_Image::set_content_image_width(200); Product_Image::set_large_image_width(200); ProductGroup::set_include_child_groups(true); ProductGroup::set_must_have_price(true); ProductGroup::set_sort_options(array('Title' => 'Alphabetical', 'Price' => 'Lowest Price')); // * * * CHECKOUT ExpiryDateField::set_short_months(true); //uses short months (e.g. Jan instead of january) for credit card expiry date. OrderFormWithoutShippingAddress::set_fixed_country_code("NZ"); //country is fixed OrderFormWithoutShippingAddress::set_postal_code_url("http://maps.google.com"); //link that can be used to check postal code OrderFormWithoutShippingAddress::set_postal_code_label("click here to check your postal code"); //label for link that can be used to check postal code OrderFormWithoutShippingAddress::set_login_invite_alternative_text('<a href="http://www.mysite.com/Security/login/?BackURL=">If you are a member then please log in.</a>'); //label for link that can be used to check postal code // * * * MEMBER EcommerceRole::set_group_name("Customers"); // * * * MODIFIERS FlatTaxModifier::set_tax("0.15", "GST", $exclusive = false); SimpleShippingModifier::set_default_charge(10); SimpleShippingModifier::set_charges_for_countries(array('US' => 10, 'NZ' => 5)); TaxModifier::set_for_country($country = "NZ", $rate = 0.15, $name = "GST", $inclexcl = "inclusive"); // * * * HELP Product::set_global_allow_purchase(false); //stops the sale of all products