本文整理汇总了PHP中OrderItem::get方法的典型用法代码示例。如果您正苦于以下问题:PHP OrderItem::get方法的具体用法?PHP OrderItem::get怎么用?PHP OrderItem::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OrderItem
的用法示例。
在下文中一共展示了OrderItem::get方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
function run($request)
{
//reset time limit
set_time_limit(1200);
//file data
$now = Date("d-m-Y-H-i");
$fileName = "export-{$now}.csv";
//data object variables
$orderStatusSubmissionLog = EcommerceConfig::get("OrderStatusLog", "order_status_log_class_used_for_submitting_order");
$fileData = "";
$offset = 0;
$count = 50;
while ($orders = Order::get()->sort("\"Order\".\"ID\" ASC")->innerJoin("OrderStatusLog", "\"Order\".\"ID\" = \"OrderStatusLog\".\"OrderID\"")->innerJoin($orderStatusSubmissionLog, "\"{$orderStatusSubmissionLog}\".\"ID\" = \"OrderStatusLog\".\"ID\"")->leftJoin("Member", "\"Member\".\"ID\" = \"Order\".\"MemberID\"")->limit($count, $offset) && ($ordersCount = $orders->count())) {
$offset = $offset + $count;
foreach ($orders as $order) {
if ($order->IsSubmitted()) {
$memberIsOK = false;
if (!$order->MemberID) {
$memberIsOK = true;
} elseif (!$order->Member()) {
$memberIsOK = true;
} elseif ($member = $order->Member()) {
$memberIsOK = true;
if ($member->IsShopAdmin()) {
$memberIsOK = false;
}
}
if ($memberIsOK) {
$items = OrderItem::get()->filter(array("OrderID" => $order->ID));
if ($items && $items->count()) {
$fileData .= $this->generateExportFileData($order->getOrderEmail(), $order->SubmissionLog()->Created, $items);
}
}
}
}
unset($orders);
}
if ($fileData) {
SS_HTTPRequest::send_file($fileData, $fileName, "text/csv");
} else {
user_error("No records found", E_USER_ERROR);
}
}
示例2: changeIsOrdered
public function changeIsOrdered($sender, $param)
{
$results = $errors = array();
try {
Dao::beginTransaction();
if (!isset($param->CallbackParameter->item_id) || !($item = OrderItem::get($param->CallbackParameter->item_id)) instanceof OrderItem) {
throw new Exception('System Error: invalid order item provided!');
}
if (!isset($param->CallbackParameter->isOrdered)) {
throw new Exception('System Error: invalid order item: isOrdered needed!');
}
$setIsOrdered = intval($param->CallbackParameter->isOrdered);
$item->setIsOrdered($setIsOrdered);
$item->addComment('Changing the isOrdered to be : ' . ($setIsOrdered === 1 ? 'ORDERED' : 'NOT ORDERED'));
$order = $item->getOrder();
$sku = $item->getProduct()->getSku();
$order->addComment('Changing the isOrdered for product (sku=' . $sku . ') to be : ' . ($setIsOrdered === 1 ? 'ORDERED' : 'NOT ORDERED'), Comments::TYPE_PURCHASING);
$item->save();
$results = $item->getJson();
Dao::commitTransaction();
} catch (Exception $ex) {
Dao::rollbackTransaction();
$errors[] = $ex->getMessage();
}
$param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
}
示例3: saveOrder
/**
* saveOrder
*
* @param unknown $sender
* @param unknown $param
*
* @throws Exception
*
*/
public function saveOrder($sender, $param)
{
$results = $errors = array();
try {
Dao::beginTransaction();
$customer = Customer::get(trim($param->CallbackParameter->customer->id));
if (!$customer instanceof Customer) {
throw new Exception('Invalid Customer passed in!');
}
if (!isset($param->CallbackParameter->applyTo) || ($applyTo = trim($param->CallbackParameter->applyTo)) === '' || !in_array($applyTo, CreditNote::getApplyToTypes())) {
throw new Exception('Invalid Apply To passed in!');
}
if (isset($param->CallbackParameter->creditNoteId) && ($creditNote = CreditNote::get(trim($param->CallbackParameter->creditNoteId))) instanceof CreditNote) {
$creditNote = $creditNote;
} else {
if (isset($param->CallbackParameter->orderId) && ($order = Order::get(trim($param->CallbackParameter->orderId))) instanceof Order) {
$creditNote = CreditNote::createFromOrder($order, $customer, trim($param->CallbackParameter->description));
} else {
$creditNote = CreditNote::create($customer, trim($param->CallbackParameter->description));
}
}
$creditNote->setShippingValue(isset($param->CallbackParameter->totalShippingCost) ? StringUtilsAbstract::getValueFromCurrency($param->CallbackParameter->totalShippingCost) : 0);
if (isset($param->CallbackParameter->shippingAddr)) {
$shippAddress = Address::create($param->CallbackParameter->shippingAddr->street, $param->CallbackParameter->shippingAddr->city, $param->CallbackParameter->shippingAddr->region, $param->CallbackParameter->shippingAddr->country, $param->CallbackParameter->shippingAddr->postCode, $param->CallbackParameter->shippingAddr->contactName, $param->CallbackParameter->shippingAddr->contactNo);
$customer->setShippingAddress($shippAddress);
}
$printItAfterSave = false;
if (isset($param->CallbackParameter->printIt)) {
$printItAfterSave = intval($param->CallbackParameter->printIt) === 1 ? true : false;
}
if (isset($param->CallbackParameter->comments)) {
$comments = trim($param->CallbackParameter->comments);
$creditNote->addComment($comments, Comments::TYPE_SALES);
}
$totalPaymentDue = $creditNote->getShippingValue();
$hasShipped = $creditNote->getOrder() instanceof Order && Shippment::countByCriteria('orderId = ?', array($creditNote->getOrder()->getId())) > 0;
$creditNoteItemsMap = array();
foreach ($param->CallbackParameter->items as $item) {
if (!($product = Product::get(trim($item->product->id))) instanceof Product) {
throw new Exception('Invalid Product passed in!');
}
$unitPrice = StringUtilsAbstract::getValueFromCurrency(trim($item->unitPrice));
$qtyOrdered = trim($item->qtyOrdered);
$totalPrice = StringUtilsAbstract::getValueFromCurrency(trim($item->totalPrice));
$itemDescription = trim($item->itemDescription);
$active = trim($item->valid);
$totalPaymentDue += $totalPrice;
if (is_numeric($item->creditNoteItemId) && !CreditNoteItem::get(trim($item->creditNoteItemId)) instanceof CreditNoteItem) {
throw new Exception('Invalid Credit Note Item passed in');
}
$unitCost = $product->getUnitCost();
$orderItem = null;
if (isset($item->orderItemId) && ($orderItem = OrderItem::get(trim($item->orderItemId))) instanceof OrderItem) {
$unitCost = $orderItem->getUnitCost();
}
$creditNoteItem = is_numeric($item->creditNoteItemId) ? CreditNoteItem::get(trim($item->creditNoteItemId))->setActive($active)->setProduct($product)->setQty($qtyOrdered)->setUnitPrice($unitPrice)->setItemDescription($itemDescription)->setUnitCost($unitCost)->setTotalPrice($totalPrice)->save() : ($orderItem instanceof OrderItem ? CreditNoteItem::createFromOrderItem($creditNote, $orderItem, $qtyOrdered, $unitPrice, $itemDescription, $unitCost, $totalPrice) : CreditNoteItem::create($creditNote, $product, $qtyOrdered, $unitPrice, $itemDescription, $unitCost, $totalPrice));
if (intval($creditNoteItem->getActive()) === 1) {
if (!isset($creditNoteItemsMap[$product->getId()])) {
$creditNoteItemsMap[$product->getId()] = 0;
}
$creditNoteItemsMap[$product->getId()] += $qtyOrdered;
}
//if we are not creating from a order, or there are shippments for this order then
if (!$creditNote->getOrder() instanceof Order || $hasShipped === true) {
switch (trim($item->stockData)) {
case 'StockOnHand':
$product->returnedIntoSOH($qtyOrdered, $creditNoteItem->getUnitCost(), '', $creditNoteItem);
break;
case 'StockOnRMA':
$product->returnedIntoRMA($qtyOrdered, $creditNoteItem->getUnitCost(), '', $creditNoteItem);
break;
default:
throw new Exception('System Error: NO where to transfer the stock: ' . trim($item->stockData) . ' for product(SKU=' . $product->getSku() . ').');
}
} else {
//revert all the shipped stock
foreach (OrderItem::getAllByCriteria('ord_item.orderId = ? and ord_item.isShipped = 1', array($creditNote->getOrder()->getId())) as $orderItem) {
$orderItem->setIsShipped(false)->save();
}
//revert all the picked stock
foreach (OrderItem::getAllByCriteria('ord_item.orderId = ? and ord_item.isPicked = 1', array($creditNote->getOrder()->getId())) as $orderItem) {
$orderItem->setIsPicked(false)->save();
}
}
}
if (($paymentMethod = PaymentMethod::get(trim($param->CallbackParameter->paymentMethodId))) instanceof PaymentMethod) {
$creditNote->setTotalPaid($totalPaidAmount = $param->CallbackParameter->totalPaidAmount)->addPayment($paymentMethod, $totalPaidAmount);
}
$creditNote->setTotalValue($totalPaymentDue)->setApplyTo($applyTo)->save();
//if need to check half credited orders
if ($creditNote->getOrder() instanceof Order && $hasShipped === false) {
//.........这里部分代码省略.........
示例4: getTotalItems
public function getTotalItems($recalculate = false)
{
if ($this->totalItems === null || $recalculate) {
$this->totalItems = OrderItem::get()->where("\"OrderAttribute\".\"OrderID\" = " . $this->ID . " AND \"OrderItem\".\"Quantity\" > 0")->count();
}
return $this->totalItems;
}
示例5: saveOrder
/**
* saveOrder
*
* @param unknown $sender
* @param unknown $param
*
* @throws Exception
*
*/
public function saveOrder($sender, $param)
{
$results = $errors = array();
try {
Dao::beginTransaction();
$customer = Customer::get(trim($param->CallbackParameter->customer->id));
if (!$customer instanceof Customer) {
throw new Exception('Invalid Customer passed in!');
}
if (!isset($param->CallbackParameter->type) || ($type = trim($param->CallbackParameter->type)) === '' || !in_array($type, Order::getAllTypes())) {
throw new Exception('Invalid type passed in!');
}
$order = null;
if (isset($param->CallbackParameter->orderId) && ($orderId = trim($param->CallbackParameter->orderId)) !== '') {
if (!($order = Order::get($orderId)) instanceof Order) {
throw new Exception('Invalid Order to edit!');
}
}
$orderCloneFrom = null;
if (isset($param->CallbackParameter->orderCloneFromId) && ($orderCloneFromId = trim($param->CallbackParameter->orderCloneFromId)) !== '') {
if (!($orderCloneFrom = Order::get($orderCloneFromId)) instanceof Order) {
throw new Exception('Invalid Order to clone from!');
}
}
$shipped = isset($param->CallbackParameter->shipped) && intval($param->CallbackParameter->shipped) === 1;
$poNo = isset($param->CallbackParameter->poNo) && trim($param->CallbackParameter->poNo) !== '' ? trim($param->CallbackParameter->poNo) : '';
if (isset($param->CallbackParameter->shippingAddr)) {
$shippAddress = $order instanceof Order ? $order->getShippingAddr() : null;
$shippAddress = Address::create($param->CallbackParameter->shippingAddr->street, $param->CallbackParameter->shippingAddr->city, $param->CallbackParameter->shippingAddr->region, $param->CallbackParameter->shippingAddr->country, $param->CallbackParameter->shippingAddr->postCode, $param->CallbackParameter->shippingAddr->contactName, $param->CallbackParameter->shippingAddr->contactNo, $param->CallbackParameter->shippingAddr->companyName, $shippAddress);
} else {
$shippAddress = $customer->getShippingAddress();
}
$printItAfterSave = false;
if (isset($param->CallbackParameter->printIt)) {
$printItAfterSave = intval($param->CallbackParameter->printIt) === 1 ? true : false;
}
if (!$order instanceof Order) {
$order = Order::create($customer, $type, null, '', OrderStatus::get(OrderStatus::ID_NEW), new UDate(), false, $shippAddress, $customer->getBillingAddress(), false, $poNo, $orderCloneFrom);
} else {
$order->setType($type)->setPONo($poNo)->save();
}
$totalPaymentDue = 0;
if (trim($param->CallbackParameter->paymentMethodId)) {
$paymentMethod = PaymentMethod::get(trim($param->CallbackParameter->paymentMethodId));
if (!$paymentMethod instanceof PaymentMethod) {
throw new Exception('Invalid PaymentMethod passed in!');
}
$totalPaidAmount = trim($param->CallbackParameter->totalPaidAmount);
$order->addPayment($paymentMethod, $totalPaidAmount);
$order = Order::get($order->getId());
$order->addInfo(OrderInfoType::ID_MAGE_ORDER_PAYMENT_METHOD, $paymentMethod->getName(), true);
if ($shipped === true) {
$order->setType(Order::TYPE_INVOICE);
}
} else {
$paymentMethod = '';
$totalPaidAmount = 0;
}
foreach ($param->CallbackParameter->items as $item) {
$product = Product::get(trim($item->product->id));
if (!$product instanceof Product) {
throw new Exception('Invalid Product passed in!');
}
if (isset($item->active) && intval($item->active) === 1 && intval($product->getActive()) !== 1 && $type === Order::TYPE_INVOICE) {
throw new Exception('Product(SKU:' . $product->getSku() . ') is DEACTIVATED, please change it to be proper product before converting it to a ' . $type . '!');
}
$unitPrice = trim($item->unitPrice);
$qtyOrdered = trim($item->qtyOrdered);
$totalPrice = trim($item->totalPrice);
$itemDescription = trim($item->itemDescription);
if (intval($item->active) === 1) {
$totalPaymentDue += $totalPrice;
if ($orderCloneFrom instanceof Order || !($orderItem = OrderItem::get($item->id)) instanceof OrderItem) {
$orderItem = OrderItem::create($order, $product, $unitPrice, $qtyOrdered, $totalPrice, 0, null, $itemDescription);
} else {
$orderItem->setActive(intval($item->active))->setProduct($product)->setUnitPrice($unitPrice)->setQtyOrdered($qtyOrdered)->setTotalPrice($totalPrice)->setItemDescription($itemDescription)->save();
$existingSellingItems = SellingItem::getAllByCriteria('orderItemId = ?', array($orderItem->getId()));
foreach ($existingSellingItems as $sellingItem) {
//DELETING ALL SERIAL NUMBER BEFORE ADDING
$sellingItem->setActive(false)->save();
}
}
$orderItem = OrderItem::get($orderItem->getId())->reCalMarginFromProduct()->resetCostNMarginFromKits()->save();
} else {
if ($orderCloneFrom instanceof Order) {
continue;
} elseif (($orderItem = OrderItem::get($item->id)) instanceof OrderItem) {
$orderItem->setActive(false)->save();
}
}
if (isset($item->serials) && count($item->serials) > 0) {
//.........这里部分代码省略.........
示例6: updateForAjax
function updateForAjax(array $js)
{
parent::updateForAjax($js);
self::apply_min_max();
if (is_array(self::$ids_of_items_adjusted) && count(self::$ids_of_items_adjusted)) {
$items = OrderItem::get()->filter(array('ID' => self::$ids_of_items_adjusted));
if ($items->count()) {
foreach ($items as $item) {
$item->updateForAjax($js);
}
}
}
return $js;
}
示例7: getProductQuestionOrderItem
/**
* retrieves order item from post / get variables.
* @return OrderItem | Null
*/
protected function getProductQuestionOrderItem()
{
$id = intval($this->owner->request->param("ID"));
if (!$id) {
$id = intval($this->owner->request->postVar("OrderItemID"));
}
if (!$id) {
$id = intval($this->owner->request->getVar("OrderItemID"));
}
if ($id) {
$this->productQuestionOrderItem = OrderItem::get()->byID($id);
}
if (!$this->productQuestionOrderItem) {
user_error("NO this->productQuestionOrderItem specified");
}
return $this->productQuestionOrderItem;
}
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce-product-questions,代码行数:21,代码来源:ProductQuestion_ProductControllerDecorator.php
示例8: getExistingItem
/**
* Gets an existing order item based on buyable and passed parameters
*
* @param DataObject $buyable
* @param Array $parameters
* @return OrderItem or null
*/
protected function getExistingItem(BuyableModel $buyable, array $parameters = array())
{
$filterString = $this->parametersToSQL($parameters);
if ($order = $this->currentOrder()) {
$orderID = $order->ID;
$obj = OrderItem::get()->where(" \"BuyableClassName\" = '" . $buyable->ClassName . "' AND\r\n\t\t\t\t\t\"BuyableID\" = " . $buyable->ID . " AND\r\n\t\t\t\t\t\"OrderID\" = " . $orderID . " " . $filterString)->First();
return $obj;
}
}
示例9: ecommercetaskupgradepickupordeliverymodifier_320
function ecommercetaskupgradepickupordeliverymodifier_320()
{
$explanation = "\r\n\t\t\t<h1>320. Removing empty Order Items</h1>\r\n\t\t\t<p>Removes all the order items without a buyable.</p>\r\n\t\t";
if ($this->retrieveInfoOnly) {
return $explanation;
} else {
echo $explanation;
}
$orderItems = OrderItem::get()->filter(array("BuyableID" => 0));
$count = $orderItems->count();
if ($count > 0) {
$style = "deleted";
} else {
$style = "created";
}
$this->DBAlterationMessageNow("There are " . $count . " items that should be removed", $style);
foreach ($orderItems as $orderItem) {
$this->DBAlterationMessageNow("Deleting order item with ID: " . $orderItem->ID, "deleted");
$orderItem->delete();
}
return 0;
}
示例10: saveOrder
/**
* saveOrder
*
* @param unknown $sender
* @param unknown $param
*
* @throws Exception
*
*/
public function saveOrder($sender, $param)
{
$results = $errors = array();
try {
Dao::beginTransaction();
$customer = Customer::get(trim($param->CallbackParameter->customer->id));
if (!$customer instanceof Customer) {
throw new Exception('Invalid Customer passed in!');
}
if (!isset($param->CallbackParameter->status) || ($status = trim($param->CallbackParameter->status)) === '' || !in_array($status, RMA::getAllStatuses())) {
throw new Exception('Invalid Status passed in!');
}
if (isset($param->CallbackParameter->RMA) && !($RMA = RMA::get(trim($param->CallbackParameter->RMA->id))) instanceof RMA) {
throw new Exception('Invalid RMA To passed in!');
}
$RMA = isset($param->CallbackParameter->RMA) && ($RMA = RMA::get(trim($param->CallbackParameter->RMA->id))->setDescription(trim($param->CallbackParameter->description))) instanceof RMA ? $RMA : RMA::create($customer, trim($param->CallbackParameter->description));
if (isset($param->CallbackParameter->order) && ($order = Order::get(trim($param->CallbackParameter->order->id))) instanceof Order) {
$RMA->setOrder($order);
}
if (isset($param->CallbackParameter->shippingAddr)) {
$shippAddress = Address::create($param->CallbackParameter->shippingAddr->street, $param->CallbackParameter->shippingAddr->city, $param->CallbackParameter->shippingAddr->region, $param->CallbackParameter->shippingAddr->country, $param->CallbackParameter->shippingAddr->postCode, $param->CallbackParameter->shippingAddr->contactName, $param->CallbackParameter->shippingAddr->contactNo, $param->CallbackParameter->shippingAddr->companyName);
$customer->setShippingAddress($shippAddress);
}
$printItAfterSave = false;
if (isset($param->CallbackParameter->printIt)) {
$printItAfterSave = intval($param->CallbackParameter->printIt) === 1 ? true : false;
}
if (isset($param->CallbackParameter->comments)) {
$comments = trim($param->CallbackParameter->comments);
$RMA->addComment($comments, Comments::TYPE_SALES);
}
$totalPaymentDue = 0;
foreach ($param->CallbackParameter->items as $item) {
$product = Product::get(trim($item->product->id));
if (!$product instanceof Product) {
throw new Exception('Invalid Product passed in!');
}
$unitPrice = trim($item->unitPrice);
$qtyOrdered = trim($item->qtyOrdered);
$totalPrice = trim($item->totalPrice);
$itemDescription = trim($item->itemDescription);
$active = trim($item->valid);
$totalPaymentDue += $totalPrice;
if (is_numeric($item->RMAItemId) && !RMAItem::get(trim($item->RMAItemId)) instanceof RMAItem) {
throw new Exception('Invalid RMA Item passed in');
}
$RMAItem = is_numeric($item->RMAItemId) ? RMAItem::get(trim($item->RMAItemId))->setActive($active)->setProduct($product)->setQty($qtyOrdered)->setItemDescription($itemDescription) : RMAItem::create($RMA, $product, $qtyOrdered, $itemDescription);
if (isset($item->orderItemId) && ($orderItem = OrderItem::get(trim($item->orderItemId))) instanceof OrderItem) {
$RMAItem->setOrderItem($orderItem)->setUnitCost($orderItem->getUnitCost());
}
if (isset($item->RMAItemId) && ($RMAItem = RMAItem::get(trim($item->RMAItemId))) instanceof RMAItem && $product->getUnitCost() != 0) {
$RMAItem->setUnitCost($RMAItem->getUnitCost())->save();
} else {
$RMAItem->setUnitCost($product->getUnitCost())->save();
}
$RMAItem->save();
}
$RMA->setTotalValue($totalPaymentDue)->setStatus($status)->save();
$results['item'] = $RMA->getJson();
// if($printItAfterSave === true)
// $results['printURL'] = '/print/rma/' . $RMA->getId() . '.html?pdf=1';
Dao::commitTransaction();
} catch (Exception $ex) {
Dao::rollbackTransaction();
// $errors[] = $ex->getMessage();
$errors[] = $ex->getTraceAsString();
}
$param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
}
示例11: preSave
public function preSave()
{
$this->setProduct($this->getProductQtyLog()->getproduct())->setLastPurchaseTime($this->getProductQtyLog()->getCreated());
switch ($this->getProductQtyLog()->getEntityName()) {
case 'ReceivingItem':
if (($receivingItem = ReceivingItem::get($this->getProductQtyLog()->getEntityId())) instanceof ReceivingItem) {
$this->setReceivingItem($receivingItem);
}
break;
case 'PurchaseOrderItem':
if (($purchaseOrderItem = PurchaseOrderItem::get($this->getProductQtyLog()->getEntityId())) instanceof PurchaseOrderItem) {
$this->setPurchaseOrderItem($purchaseOrderItem);
}
break;
case 'OrderItem':
if (($orderItem = OrderItem::get($this->getProductQtyLog()->getEntityId())) instanceof OrderItem) {
$this->setOrderItem($orderItem);
}
break;
case 'CreditNoteItem':
if (($creditNoteItem = CreditNoteItem::get($this->getProductQtyLog()->getEntityId())) instanceof CreditNoteItem) {
$this->setCreditNoteItem($creditNoteItem);
}
break;
}
}