/** * Link to add this product to cart. * @return string link */ public function addLink() { return ShoppingCart_Controller::add_item_link($this); }
/** * @return string */ public function addLink() { $buyable = $this->Buyable(); return $buyable ? ShoppingCart_Controller::add_item_link($buyable, $this->uniquedata()) : ''; }
/** * * @return String */ function AddToCartAndGoToCheckoutLink() { $array = $this->linkParameters(); $array["BackURL"] = urlencode(CheckoutPage::find_link()); return ShoppingCart_Controller::add_item_link($this->ID, $this->ClassName, $array); }
public function testSecurityToken() { $enabled = SecurityToken::is_enabled(); // enable security tokens SecurityToken::enable(); $productId = $this->mp3player->ID; // link should contain the security-token $link = ShoppingCart_Controller::add_item_link($this->mp3player); $this->assertRegExp('{^shoppingcart/add/Product/' . $productId . '\\?SecurityID=[a-f0-9]+$}', $link); // should redirect back to the shop $response = $this->get($link); $this->assertEquals($response->getStatusCode(), 302); // disable security token for cart-links Config::inst()->update('ShoppingCart_Controller', 'disable_security_token', true); $link = ShoppingCart_Controller::add_item_link($this->mp3player); $this->assertEquals('shoppingcart/add/Product/' . $productId, $link); // should redirect back to the shop $response = $this->get($link); $this->assertEquals($response->getStatusCode(), 302); SecurityToken::disable(); Config::inst()->update('ShoppingCart_Controller', 'disable_security_token', false); $link = ShoppingCart_Controller::add_item_link($this->mp3player); $this->assertEquals('shoppingcart/add/Product/' . $productId, $link); // should redirect back to the shop $response = $this->get($link); $this->assertEquals($response->getStatusCode(), 302); SecurityToken::enable(); // should now return a 400 status $response = $this->get($link); $this->assertEquals($response->getStatusCode(), 400); // restore previous setting if (!$enabled) { SecurityToken::disable(); } }
public function addLink() { return ShoppingCart_Controller::add_item_link($this->Buyable(), $this->uniquedata()); }
/** * * @return String (URLSegment) **/ function IncrementLink() { return ShoppingCart_Controller::add_item_link($this->BuyableID, $this->BuyableClassName, $this->linkParameters()); }
function addLink() { return ShoppingCart_Controller::add_item_link($this->_productID); }
public function testVariations() { $this->loadFixture('shop/tests/fixtures/variations.yml'); $ballRoot = $this->objFromFixture('Product', 'ball'); $ballRoot->publish('Stage', 'Live'); $ball1 = $this->objFromFixture('ProductVariation', 'redlarge'); $ball2 = $this->objFromFixture('ProductVariation', 'redsmall'); // Add the two variation items $r = $this->get(ShoppingCart_Controller::add_item_link($ball1), null, $this->ajaxHeaders); $this->assertTrue($r instanceof AjaxHTTPResponse); $r = $this->get(ShoppingCart_Controller::add_item_link($ball2)); $this->assertFalse($r instanceof AjaxHTTPResponse); $items = ShoppingCart::curr()->Items(); $this->assertNotNull($items); $this->assertEquals($items->Count(), 2, 'There are 2 items in the cart'); // Remove one and see what happens $r = $this->get(ShoppingCart_Controller::remove_all_item_link($ball1), null, $this->ajaxHeaders); $this->assertTrue($r instanceof AjaxHTTPResponse); $this->assertEquals($items->Count(), 1, 'There is 1 item in the cart'); $this->assertFalse($this->cart->get($ball1), "first item not in cart"); $this->assertNotNull($this->cart->get($ball1), "second item is in cart"); }
/** * link use to add (one) to cart *@return String */ function IncrementLink() { //we can do this, because by default add link adds one return ShoppingCart_Controller::add_item_link($this->ID, $this->ClassName, $this->linkParameters()); }