本文整理汇总了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;
}