本文整理汇总了PHP中OrderItem::model方法的典型用法代码示例。如果您正苦于以下问题:PHP OrderItem::model方法的具体用法?PHP OrderItem::model怎么用?PHP OrderItem::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OrderItem
的用法示例。
在下文中一共展示了OrderItem::model方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dirname
<?php
namespace Afosto\ActiveAnts;
require_once dirname(__FILE__) . '/vendor/autoload.php';
//Include our configs
require_once dirname(__FILE__) . '/../config.php';
//Make sure this directory is writable
$cacheDirectory = dirname(__FILE__) . '/../cache/';
App::start($url, $user, $password, $cacheDirectory);
$product = Product::model()->setName('testProduct')->setSku('testSku');
if (!$product->save()) {
echo $product->getMessage();
}
$item = OrderItem::model()->setSku('testSku', false)->setGrossPrice(1.21)->setName('testProduct')->setTaxRate(21);
$address = Address::model()->setName('Afosto SaaS BV')->setAddress('Protonstraat', 9, 'a')->setCity('Groningen')->setCountry('NL')->setPostalcode('9743AL');
$order = Order::model()->setEmail('support@afosto.com')->setOrderId('#' . rand(100, 999))->setPhoneNumber('test')->addOrderItem($item)->setBillingAddress($address)->setShippingAddress();
//$order->setPickupPoint('NL-111101', '1111AA', 'Straatnaam 10a' , 'Groningen');
if (!$order->save()) {
echo $order->getMessage();
}
$purchase = PurchaseOrder::model()->addItem('testSku', 1)->addReference('testPurchaseOrder');
if (!$purchase->save()) {
echo $purchase->getMessage();
}
foreach (Stock::model()->findAll() as $stock) {
echo $stock->sku . ': ' . $stock->stock . "\n";
}
示例2: afterSave
public function afterSave()
{
$num = OrderItem::model()->count(array('condition' => 'item_id=:item_id ', 'params' => array(':item_id' => $this->item_id)));
$model = Item::model()->findByPk($this->item_id);
$model->deal_count = $num;
$model->save();
return parent::afterSave();
}
示例3: actionCheckStock
public function actionCheckStock()
{
$number = $_GET['number'];
$sku_id = $_GET['sku_id'];
$sku = Sku::model()->findByPk($sku_id);
$criteria = new CDbCriteria();
$criteria->addCondition('item_id=:item_id');
$criteria->addCondition('price=:price');
$criteria->addCondition('props_name=:props_name');
$criteria->params[':item_id'] = $sku->item_id;
$criteria->params[':price'] = $sku->price;
$criteria->params[':props_name'] = $sku->props_name;
$orderItem = OrderItem::model()->find($criteria);
if ($sku->stock + $orderItem->quantity < $number || $number <= 0) {
echo 0;
} else {
echo 1;
}
}
示例4: getProducts
public function getProducts($which = 'after')
{
$order = array();
$products = array();
if (($which == 'after' || $which == 'both') && isset($this->_SupplierProduct[$this->delivery_date_id])) {
$products = $this->_SupplierProduct[$this->delivery_date_id];
} else {
if ($which == 'before' && isset($this->_SupplierProduct_Before[$this->delivery_date_id])) {
$products = $this->_SupplierProduct_Before[$this->delivery_date_id];
}
}
if ($which == 'both' && isset($this->_SupplierProduct_Before[$this->delivery_date_id])) {
foreach ($this->_SupplierProduct_Before[$this->delivery_date_id] as $pid => $qty) {
if (!isset($products[$pid])) {
$products[$pid] = $qty;
}
}
}
if (empty($products)) {
return $order;
}
$Order = $this->_getOrder($this->_user->id, $this->delivery_date_id, $this->_location_id);
$Order = $Order->id ? $Order : false;
//We don't to create a new order
foreach ($products as $id => $qty) {
$OI = null;
if ($Order) {
$OI = OrderItem::model()->findByAttributes(array('supplier_product_id' => $id, 'order_id' => $Order->id));
}
if (!$OI) {
$OI = new OrderItem();
$OI->supplier_product_id = $id;
}
$SP = $OI->SupplierProduct;
$OI->quantity = $qty;
//Only update price etc if it hasn't been set yet.
if (empty($OI->name)) {
$OI->price = $SP->item_sales_price;
$OI->name = $SP->name;
$OI->unit = $SP->unit;
$OI->packing_station_id = $SP->packing_station_id;
}
$order[] = $OI;
}
return $order;
}
示例5: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer $id the ID of the model to be loaded
* @return OrderItem the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model = OrderItem::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例6: getCanBeDeleted
/**
* Predicate for checking wether the order can be deleted or not.
*
* @return boolean
*/
public function getCanBeDeleted()
{
return !OrderItem::model()->forOrder($this)->exists();
}
示例7: getExtras_total
public function getExtras_total()
{
$criteria = new CDbCriteria();
$criteria->select = 'SUM(price * quantity) as date_total';
$criteria->with = 'Order';
$criteria->condition = 'delivery_date_id=:dateId AND user_id=:customerId';
$criteria->params = array(':dateId' => $this->delivery_date_id, ':customerId' => $this->user_id);
$extras = OrderItem::model()->find($criteria);
$extrasTotal = $extras ? $extras->date_total : 0;
return $extrasTotal;
}