public function setUp()
 {
     parent::setUp();
     ShopTest::setConfiguration();
     //set up steps
     SteppedCheckout::setupSteps();
     //use default steps
     $this->socks = $this->objFromFixture("Product", "socks");
     $this->socks->publish('Stage', 'Live');
     $checkoutpage = $this->objFromFixture("CheckoutPage", "checkout");
     $checkoutpage->publish('Stage', 'Live');
     $this->checkout = new CheckoutPage_Controller();
     $this->checkout->handleRequest(new SS_HTTPRequest("GET", "checkout"), DataModel::inst());
     $this->cart = $this->objFromFixture("Order", "cart");
     ShoppingCart::singleton()->setCurrent($this->cart);
 }
 public function setUp()
 {
     parent::setUp();
     ProductCategory::config()->must_have_price = false;
     $this->products = $this->objFromFixture('ProductCategory', 'products');
     $this->products->publish('Stage', 'Live');
     $this->clothing = $this->objFromFixture('ProductCategory', 'clothing');
     $this->clothing->publish('Stage', 'Live');
     $this->electronics = $this->objFromFixture('ProductCategory', 'electronics');
     $this->electronics->publish('Stage', 'Live');
     $this->socks = $this->objFromFixture('Product', 'socks');
     $this->socks->publish('Stage', 'Live');
     $this->tshirt = $this->objFromFixture('Product', 'tshirt');
     $this->tshirt->publish('Stage', 'Live');
     $this->hdtv = $this->objFromFixture('Product', 'hdtv');
     $this->hdtv->publish('Stage', 'Live');
     $this->beachball = $this->objFromFixture('Product', 'beachball');
     $this->beachball->publish('Stage', 'Live');
     $this->mp3player = $this->objFromFixture('Product', 'mp3player');
     $this->mp3player->publish('Stage', 'Live');
     Versioned::reading_stage('Live');
 }
 public function testTiersWithPromotionalPricing()
 {
     $this->p2->PromoActive = true;
     $this->p2->PromoType = 'Percent';
     $this->p2->PromoPercent = 0.5;
     $this->p2->write();
     $this->p2->publish('Stage', 'Live');
     $price = round(14.99 * 0.25, 2);
     $qty = 10;
     $tiers = $this->p2->getPrices();
     $this->assertEquals(3, $tiers->count());
     $this->assertEquals($price, $tiers->offsetGet(2)->Price);
     $this->assertEquals(7.5, $tiers->offsetGet(2)->OriginalPrice);
     ShoppingCart::singleton()->add($this->p2, $qty);
     ShoppingCart::curr()->calculate();
     $this->assertEquals($price * $qty, ShoppingCart::curr()->SubTotal());
 }
 function run($request)
 {
     if (!DataObject::get_one('Product')) {
         if (!DataObject::get_one('ProductGroup')) {
             $productGroup1 = new ProductGroup();
             $productGroup1->Title = 'Products';
             $productGroup1->Content = "\r\n\t\t\t\t\t<p>This is the top level products page, it uses the <em>product group</em> page type, and it allows you to show your products checked as 'featured' on it. It also allows you to nest <em>product group</em> pages inside it.</p>\r\n\t\t\t\t\t<p>For example, you have a product group called 'DVDs', and inside you have more product groups like 'sci-fi', 'horrors' or 'action'.</p>\r\n\t\t\t\t\t<p>In this example we have setup a main product group (this page), with a nested product group containing 2 example products.</p>\r\n\t\t\t\t";
             $productGroup1->URLSegment = 'products';
             $productGroup1->writeToStage('Stage');
             $productGroup1->publish('Stage', 'Live');
             DB::alteration_message('Product group page \'Products\' created', 'created');
         }
         $content = '<p>This is a <em>product</em>. It\'s description goes into the Content field as a standard SilverStripe page would have it\'s content. This is an ideal place to describe your product.</p>';
         $page1 = new Product();
         $page1->Title = 'Example product';
         $page1->Content = $content . '<p>You may also notice that we have checked it as a featured product and it will be displayed on the main Products page.</p>';
         $page1->URLSegment = 'example-product';
         $page1->ParentID = $productGroup1->ID;
         $page1->Price = '15.00';
         $page1->FeaturedProduct = true;
         $page1->writeToStage('Stage');
         $page1->publish('Stage', 'Live');
         DB::alteration_message('Product page \'Example product\' created', 'created');
         $page2 = new Product();
         $page2->Title = 'Example product 2';
         $page2->Content = $content;
         $page2->URLSegment = 'example-product-2';
         $page2->ParentID = $productGroup1->ID;
         $page2->Price = '25.00';
         $page2->writeToStage('Stage');
         $page2->publish('Stage', 'Live');
         DB::alteration_message('Product page \'Example product 2\' created', 'created');
     } else {
         DB::alteration_message('No products created as they already exist.');
     }
 }
 /**
  * When the ecommerce module is first installed, and db/build
  * is invoked, create some default records in the database.
  */
 function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     if (!DataObject::get_one('Product')) {
         if (!DataObject::get_one('ProductGroup')) {
             singleton('ProductGroup')->requireDefaultRecords();
         }
         if ($group = DataObject::get_one('ProductGroup', '', true, "\"ParentID\" DESC")) {
             $content = '<p>This is a <em>product</em>. It\'s description goes into the Content field as a standard SilverStripe page would have it\'s content. This is an ideal place to describe your product.</p>';
             $page1 = new Product();
             $page1->Title = 'Example product';
             $page1->Content = $content . '<p>You may also notice that we have checked it as a featured product and it will be displayed on the main Products page.</p>';
             $page1->URLSegment = 'example-product';
             $page1->ParentID = $group->ID;
             $page1->Price = '15.00';
             $page1->Weight = '0.50';
             $page1->Model = 'Joe Bloggs';
             $page1->FeaturedProduct = true;
             $page1->writeToStage('Stage');
             $page1->publish('Stage', 'Live');
             DB::alteration_message('Product page \'Example product\' created', 'created');
             $page2 = new Product();
             $page2->Title = 'Example product 2';
             $page2->Content = $content;
             $page2->URLSegment = 'example-product-2';
             $page2->ParentID = $group->ID;
             $page2->Price = '25.00';
             $page2->Weight = '1.2';
             $page2->Model = 'Jane Bloggs';
             $page2->writeToStage('Stage');
             $page2->publish('Stage', 'Live');
             DB::alteration_message('Product page \'Example product 2\' created', 'created');
         }
     }
 }