コード例 #1
0
 function setUp()
 {
     parent::setUp();
     /* Set the modifiers to test */
     Order::set_modifiers(array('SimpleShippingModifier', 'TaxModifier'));
     /* Set the tax configuration on a per-country basis to test */
     TaxModifier::set_for_country('NZ', 0.125, 'GST', 'inclusive');
     TaxModifier::set_for_country('UK', 0.175, 'VAT', 'exclusive');
     /* Let's check that we have the Payment module installed properly */
     $this->assertTrue(class_exists('Payment'), 'Payment module is installed.');
     /* Set the site currency to NZD - this updates all the pricing labels from USD to NZD */
     Payment::set_site_currency('NZD');
     /* Set up the simple shipping calculator to test */
     SimpleShippingModifier::set_default_charge(10);
     SimpleShippingModifier::set_charges_for_countries(array('NZ' => 5, 'UK' => 20));
 }
コード例 #2
0
 function testTaxModifier()
 {
     /* Add 2 of the product-1b to the shopping cart */
     $this->get('product-1b/add');
     $this->get('product-1b/add');
     /* Log our NZ member in so we can assert they see the GST component */
     $this->session()->inst_set('loggedInAs', $this->idFromFixture('Member', 'member'));
     /* 12.5% GST appears to our NZ user logged in */
     $this->get('checkout/');
     $this->assertPartialMatchBySelector('tr.taxmodifier td', array('12.5% GST (included in the above price)'));
     /* Let's check the totals to make sure GST wasn't being added (which is important!) */
     /* NZD is shown as the label, since it was set as the site currency in setUp() */
     $this->assertExactMatchBySelector('#Table_Order_Total', '$1,205.00 NZD');
     /* Let's sneakily change the GST to be exclusive, altering the checkout total */
     TaxModifier::set_for_country('NZ', 0.125, 'GST', 'exclusive');
     /* See what the checkout page has got now */
     $this->get('checkout/');
     /* Check the total, it has changed since the GST is now exclusive */
     $this->assertExactMatchBySelector('#Table_Order_Total', '$1,355.63 NZD');
     /* Member logs out */
     $this->session()->inst_set('loggedInAs', null);
 }
コード例 #3
0
 function old_testTaxModifier()
 {
     $product1b = $this->objFromFixture('Product', 'p1b');
     // Add 2 of the product-1b to the shopping cart
     $this->get($product1b->addLink());
     $this->get($product1b->addLink());
     // Log our NZ member in so we can assert they see the GST component
     $this->session()->inst_set('loggedInAs', $this->idFromFixture('Member', 'member'));
     // 12.5% GST appears to our NZ user logged in
     $response = $this->get('checkout/');
     $this->assertPartialMatchBySelector('tr.taxmodifier td', array('12.5% GST (included in the above price)'));
     // Let's check the totals to make sure GST wasn't being added (which is important!)
     // NZD is shown as the label, since it was set as the site currency in setUp()
     $this->assertExactMatchBySelector('#Table_Order_Total', '$1,205.00');
     // Let's sneakily change the GST to be exclusive, altering the checkout total
     TaxModifier::set_for_country('NZ', 0.125, 'GST', 'exclusive');
     // See what the checkout page has got now
     $this->get('checkout/');
     // Check the total, it has changed since the GST is now exclusive
     $this->assertExactMatchBySelector('#Table_Order_Total', '$1,355.63');
     // Member logs out
     $this->session()->inst_set('loggedInAs', null);
 }
コード例 #4
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