本文整理匯總了PHP中Model_Order::add_product方法的典型用法代碼示例。如果您正苦於以下問題:PHP Model_Order::add_product方法的具體用法?PHP Model_Order::add_product怎麽用?PHP Model_Order::add_product使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Model_Order
的用法示例。
在下文中一共展示了Model_Order::add_product方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: test_saved_order_is_fixed
/**
* Tests to ensure that a saved order cannot have new products added to it
*
* @return null
*/
public function test_saved_order_is_fixed()
{
// Create a new product first
$product = new Model_Vendo_Product();
$product->set_fields(array('name' => 'Unit Test', 'price' => '9.99', 'description' => 'This is a unit test.', 'order' => '1'));
$product->save();
$order = new Model_Order();
$order->user_id = self::$user->id;
$order->address_id = self::$user->address_id;
$order->contact_id = self::$contact->id;
$order->add_product($product, 1);
$order->save();
try {
$order->add_product($product, 1);
} catch (Exception $e) {
$this->assertEquals('Saved orders cannot be modified!', $e->getMessage());
$order->delete();
$product->delete();
return;
}
$order->delete();
$product->delete();
$this->fail('Orders cannot be modified once saved.');
}