本文整理匯總了PHP中OrderDetail::fromArray方法的典型用法代碼示例。如果您正苦於以下問題:PHP OrderDetail::fromArray方法的具體用法?PHP OrderDetail::fromArray怎麽用?PHP OrderDetail::fromArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OrderDetail
的用法示例。
在下文中一共展示了OrderDetail::fromArray方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: executeFormWidget
public function executeFormWidget(dmWebRequest $request)
{
$form = new OrderForm();
if ($request->hasParameter($form->getName()) && $form->bindAndValid($request)) {
$order = $form->save();
$order->setUid(md5(rand(1111, 9999) . time()));
$order->save();
// link order details
$this->shopping_cart = $shopping_cart = $this->getUser()->getShoppingCart();
$this->items = $shopping_cart->getItems();
foreach ($shopping_cart->getItems() as $i => $item) {
$od = new OrderDetail();
$od->fromArray(array('product_id' => $item->getId(), 'order_id' => $order->id, 'quantity' => $item->getQuantity(), 'price' => $item->getPrice()));
$od->save();
}
if (sfConfig::get('app_send_order', false)) {
dm::enableMailer();
//send mail
$message = $this->getMailer()->compose($_from = dmConfig::get('orderEmail'), $_to = array($order->email, dmConfig::get('orderEmail')), $_subj = '[' . dmConfig::get('siteName') . '] thanks for order');
$message->setBody($this->getPartial('order/mailOrder', array('order' => $order, 'companyName' => dmConfig::get('companyName'), 'companyPhone' => dmConfig::get('companyPhone'), 'siteUrl' => dmConfig::get('siteUrl'), 'siteName' => dmConfig::get('siteName'))));
$message->setContentType('text/html');
$this->getMailer()->send($message);
}
// if send order
// clear cart now
$shopping_cart->clear();
//redirect to order info
$this->redirect($this->getHelper()->link('main/ordershow?uid=' . $order->uid)->getHref());
//$this->redirectBack();
}
$this->forms['Order'] = $form;
}