本文整理汇总了PHP中Model_Order类的典型用法代码示例。如果您正苦于以下问题:PHP Model_Order类的具体用法?PHP Model_Order怎么用?PHP Model_Order使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Model_Order类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: button
/**
* generates HTML for apy buton
* @param Model_Order $order
* @return string
*/
public static function button(Model_Order $order)
{
if (Core::config('payment.bitpay_apikey') != '' and Theme::get('premium') == 1 and Auth::instance()->logged_in() and $order->loaded()) {
return View::factory('pages/bitpay/button', array('order' => $order));
}
return '';
}
示例2: sendPush
public function sendPush($sender, $sn, $message)
{
return;
//发送推送通知
include APPLICATION_PATH . 'libs/ApnsPHP/Log/Interface.php';
include APPLICATION_PATH . 'libs/ApnsPHP/Log/Embedded.php';
include APPLICATION_PATH . 'libs/ApnsPHP/Log/Null.php';
include APPLICATION_PATH . 'libs/ApnsPHP/Abstract.php';
include APPLICATION_PATH . 'libs/ApnsPHP/Exception.php';
include APPLICATION_PATH . 'libs/ApnsPHP/Feedback.php';
include APPLICATION_PATH . 'libs/ApnsPHP/Message.php';
include APPLICATION_PATH . 'libs/ApnsPHP/Push.php';
include APPLICATION_PATH . 'libs/ApnsPHP/Message/Custom.php';
include APPLICATION_PATH . 'libs/ApnsPHP/Message/Exception.php';
include APPLICATION_PATH . 'libs/ApnsPHP/Push/Server.php';
include APPLICATION_PATH . 'libs/ApnsPHP/Push/Exception.php';
include APPLICATION_PATH . 'libs/ApnsPHP/Push/Server/Exception.php';
$order = new Model_Order($sn);
$passengerDeviceId = $order->get('passenger_device_id');
$ofd = new Model_OrderForDriver($sn);
$driver = new Model_Driver($ofd->get('driver_code'));
$driverDeviceId = $driver->get('device_id');
//$certSuffix = APPLICATION_ENV == 'development' ? '-dev.pem' : '.pem';
$certSuffix = '-dev.pem';
$passengerCert = APPLICATION_PATH . '/data/passenger' . $certSuffix;
$driverCert = APPLICATION_PATH . '/data/driver' . $certSuffix;
if ($sender == Model_OrderConversation::SENDER_DRIVER) {
$this->sendPushToDevice($passengerCert, $passengerDeviceId, $message, $sn);
} elseif ($sender == Model_OrderConversation::SENDER_PASSENGER) {
$this->sendPushToDevice($driverCert, $driverDeviceId, $message, $sn);
} else {
$this->sendPushToDevice($passengerCert, $passengerDeviceId, $message, $sn);
$this->sendPushToDevice($driverCert, $driverDeviceId, $message, $sn);
}
}
示例3: form
/**
* generates HTML form
* @param Model_Product $order
* @return string
*/
public static function form(Model_Order $order)
{
if (Core::config('payment.authorize_login') != '' and Core::config('payment.authorize_key') != '' and Auth::instance()->logged_in() and $order->loaded() and Theme::get('premium') == 1) {
return View::factory('pages/authorize/form', array('order' => $order));
}
return '';
}
示例4: action_form
/**
* [action_form] generates the form to pay at paypal
*/
public function action_form()
{
$this->auto_render = FALSE;
$order_id = $this->request->param('id');
$order = new Model_Order();
$order->where('id_order', '=', $order_id)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find();
if ($order->loaded()) {
// dependant on product we have different names
if ($order->id_product == Paypal::to_featured) {
$item_name = __('Advertisement to featured');
} else {
if ($order->id_product == Paypal::to_top) {
$item_name = __('Advertisement to top');
} else {
$item_name = $order->description . __(' category');
}
}
$paypal_url = Core::config('payment.sandbox') ? Paypal::url_sandbox_gateway : Paypal::url_gateway;
$paypal_data = array('order_id' => $order_id, 'amount' => number_format($order->amount, 2, '.', ''), 'site_name' => core::config('general.site_name'), 'site_url' => URL::base(TRUE), 'paypal_url' => $paypal_url, 'paypal_account' => core::config('payment.paypal_account'), 'paypal_currency' => core::config('payment.paypal_currency'), 'item_name' => $item_name);
$this->template = View::factory('paypal', $paypal_data);
$this->response->body($this->template->render());
} else {
Alert::set(Alert::INFO, __('Order could not be loaded'));
$this->request->redirect(Route::url('default'));
}
}
示例5: button
/**
* generates HTML for apy buton
* @param Model_Order $order
* @return string
*/
public static function button(Model_Order $order)
{
if (Core::config('payment.paymill_private') != '' and Core::config('payment.paymill_public') != '' and Theme::get('premium') == 1 and $order->loaded()) {
return View::factory('pages/paymill/button', array('order' => $order));
}
return '';
}
示例6: action_pay
/**
* [action_form] generates the form to pay at paypal
*/
public function action_pay()
{
$this->auto_render = FALSE;
$order_id = $this->request->param('id');
$order = new Model_Order();
$order->where('id_order', '=', $order_id)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find();
if ($order->loaded()) {
// case when selling advert
if ($order->id_product == Model_Order::PRODUCT_AD_SELL) {
$paypal_account = $order->ad->paypal_account();
$currency = i18n::get_intl_currency_symbol();
if (isset($order->ad->cf_shipping) and Valid::numeric($order->ad->cf_shipping) and $order->ad->cf_shipping > 0) {
$order->amount = $order->amount + $order->ad->cf_shipping;
}
} else {
$paypal_account = core::config('payment.paypal_account');
$currency = core::config('payment.paypal_currency');
}
$paypal_url = Core::config('payment.sandbox') ? Paypal::url_sandbox_gateway : Paypal::url_gateway;
$paypal_data = array('order_id' => $order_id, 'amount' => number_format($order->amount, 2, '.', ''), 'site_name' => core::config('general.site_name'), 'site_url' => URL::base(TRUE), 'paypal_url' => $paypal_url, 'paypal_account' => $paypal_account, 'paypal_currency' => $currency, 'item_name' => $order->description);
$this->template = View::factory('paypal', $paypal_data);
$this->response->body($this->template->render());
} else {
Alert::set(Alert::INFO, __('Order could not be loaded'));
$this->redirect(Route::url('default'));
}
}
示例7: action_checkout
/**
* pay an invoice, renders the paymenthods button, anyone with an ID of an order can pay it, we do not have control
* @return [type] [description]
*/
public function action_checkout()
{
$order = new Model_Order($this->request->param('id'));
if ($order->loaded()) {
//hack jquery paymill
Paymill::jquery();
//if paid...no way jose
if ($order->status != Model_Order::STATUS_CREATED) {
Alert::set(Alert::INFO, __('This order was already paid.'));
$this->redirect(Route::url('default'));
}
//checks coupons or amount of featured days
$order->check_pricing();
//template header
$this->template->title = __('Checkout') . ' ' . Model_Order::product_desc($order->id_product);
Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Home'))->set_url(Route::url('default')));
Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Pricing'))->set_url(Route::url('pricing')));
Breadcrumbs::add(Breadcrumb::factory()->set_title($this->template->title));
Controller::$full_width = TRUE;
$this->template->bind('content', $content);
$this->template->content = View::factory('pages/ad/checkout', array('order' => $order));
} else {
//throw 404
throw HTTP_Exception::factory(404, __('Page not found'));
}
}
示例8: action_commit
public function action_commit()
{
$user_id = \Session::get(self::SESSION_KEY_USER_ID);
$user = Model_Member::find($user_id);
$address = \Session::get(self::SESSION_KEY_ADDRESS);
/*------make order----------------------------------------------------------*/
$order = new Model_Order();
$order->member_id = $user->id;
$order->postalcode = $address['postalcode'];
$order->destination = $address['address'] . $address['billname'] . $address['companyname'];
$date = time();
$order->order_date = date('Y-m-d H:i:s', $date);
$order->print_flag = 0;
$order->status = 0;
$order->save();
/*-----make orderline------------------------*/
$cart = \Session::get(self::SESSION_KEY_CART);
foreach ($cart['orders'] as $orderline) {
$item_id = $orderline['item_id'];
$item = Model_Item::find($item_id);
$num = $orderline['quantity'];
$size = $orderline['size'];
$neworderline = new Model_Orderline();
$neworderline->order_id = $order->id;
$neworderline->item_id = $item_id;
$neworderline->num = $num;
$neworderline->size = $size;
$neworderline->save();
$earning = new Model_Earning();
$earning->member_id = $user->id;
$earning->item_id = $item_id;
$earning->size = $size;
switch ($size) {
case 'S':
$unit_price = $neworderline->item->unit_price_s;
break;
case 'M':
$unit_price = $neworderline->item->unit_price_m;
break;
case 'L':
$unit_price = $neworderline->item->unit_price_m;
break;
default:
$unit_price = $neworderline->item->unit_price;
break;
}
$earning->unit_price = $unit_price;
$earning->num = $num;
$earning->date = date('Y-m-d H:i:s', $date);
$earning->category = $item->category;
$earning->item_name = $item->name;
$now = date('Ymd');
$birthday = date('Ymd', strtotime($user->birthday));
$earning->age = (int) floor(($now - $birthday) / 10000);
$earning->save();
}
\Session::delete(self::SESSION_KEY_CART);
return Response::redirect('index.php/message/commit');
}
示例9: init
public function init()
{
parent::init();
$sn = strtoupper(trim($this->_getParam('sn', '')));
$order = new Model_Order($sn);
if (empty($sn) || !$order->exists()) {
$this->error('Order Not Found.');
}
$this->sn = $sn;
$this->order = $order;
}
示例10: action_historyin
public function action_historyin($order_id)
{
if (empty(\Session::get(self::SESSION_KEY_CART))) {
\Session::set(self::SESSION_KEY_CART, array('orders' => array()));
}
$cart = \Session::get(self::SESSION_KEY_CART);
$order = Model_Order::find($order_id);
$total_money = 0;
foreach ($order->orderline as $orderline) {
$item = Model_Item::find($orderline['item_id']);
$quantity = $orderline['num'];
switch ($orderline['size']) {
case 'S':
$price = $item->unit_price_s;
break;
case 'M':
$price = $item->unit_price_m;
break;
case 'L':
$price = $item->unit_price_l;
break;
default:
$price = $item->unit_price;
break;
}
$money = $price * $quantity;
array_push($cart['orders'], array('item_id' => $item['id'], 'item_name' => $item['name'], 'size' => $orderline['size'], 'quantity' => $quantity, 'money' => $money));
}
foreach ($cart['orders'] as $order) {
$total_money += $order['money'];
}
$cart['total_money'] = $total_money;
\Session::set(self::SESSION_KEY_CART, $cart);
return Response::redirect('mtpizza/cart');
}
示例11: renew
/**
* expired featured ads
* @return void
*/
public static function renew()
{
if (Core::config('general.subscriptions') == TRUE) {
//get expired subscription that are active
$subscriptions = new Model_Subscription();
$subscriptions = $subscriptions->where('status', '=', 1)->where('expire_date', '<=', Date::unix2mysql())->order_by('created', 'desc')->find_all();
foreach ($subscriptions as $s) {
//disable the plan
$s->status = 0;
try {
$s->save();
} catch (Exception $e) {
throw HTTP_Exception::factory(500, $e->getMessage());
}
$plan = $s->plan;
if ($plan->loaded() and $plan->status == 1) {
//generate a new order
$order = Model_Order::new_order(NULL, $s->user, $plan->id_plan, $plan->price, core::config('payment.paypal_currency'), __('Subscription to ') . $plan->name);
//free plan no checkout
if ($plan->price == 0) {
$order->confirm_payment('cash');
} else {
$checkout_url = $s->user->ql('default', array('controller' => 'plan', 'action' => 'checkout', 'id' => $order->id_order));
$s->user->email('plan-expired', array('[PLAN.NAME]' => $plan->name, '[URL.CHECKOUT]' => $checkout_url));
}
}
//if plan loaded
}
//end foreach
}
//if subscription active
}
示例12: action_order
public function action_order()
{
define("SECONDS_PER_DAY", 3600 * 24);
$now = time();
$cart = Session::get('cart');
$user = Model_User::find($this->sessUser->id);
$cart_info = [];
$order = Model_Order::forge();
$order->user_id = $user->id;
$order->created_at = $now;
$order->save();
if (!is_null($cart)) {
foreach ($cart as $product_id => $quantity) {
$product = Model_Product::find($product_id);
$order_product = Model_OrderProduct::forge();
$order_product->order_id = $order->id;
$order_product->product_id = $product->id;
$order_product->quantity = $quantity;
$order_product->price = $product->price;
$order_product->save();
}
}
Session::delete('cart');
return Response::redirect('/cart');
}
示例13: action_create
public function action_create()
{
try {
if (!Valid::email(core::request('email'))) {
$this->_error(__('Invalid email'), 501);
} elseif (!is_numeric(core::request('id_product'))) {
$this->_error(__('Invalid product'), 501);
} else {
$product = new Model_Product(core::request('id_product'));
if ($product->loaded()) {
$user = Model_User::create_email(core::request('email'), core::request('name'));
$order = Model_Order::new_order($user, $product);
$order->confirm_payment(core::request('paymethod', 'API'), core::request('txn_id'), core::request('pay_date'), core::request('amount'), core::request('currency'), core::request('fee'));
//adding the notes
$order->notes = core::request('notes');
$order->save();
$this->rest_output(array('order' => self::get_order_array($order)));
} else {
$this->_error(__('Something went wrong'), 501);
}
}
} catch (Kohana_HTTP_Exception $khe) {
$this->_error($khe);
}
}
示例14: action_pay
public function action_pay()
{
$this->auto_render = FALSE;
$order_id = $this->request->param('id');
$order = new Model_Order();
$order->where('id_order', '=', $order_id)->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find();
if ($order->loaded()) {
$paypal_url = Core::config('payment.sandbox') ? Paypal::url_sandbox_gateway : Paypal::url_gateway;
$paypal_data = array('order_id' => $order_id, 'amount' => number_format($order->amount, 2, '.', ''), 'site_name' => core::config('general.site_name'), 'return_url' => Route::url('default', array('controller' => 'product', 'action' => 'goal', 'id' => $order->id_order)), 'paypal_url' => $paypal_url, 'paypal_account' => core::config('payment.paypal_account'), 'paypal_currency' => $order->currency, 'item_name' => $order->product->title);
$this->template = View::factory('paypal', $paypal_data);
$this->response->body($this->template->render());
} else {
Alert::set(Alert::INFO, __('Order could not be loaded'));
$this->redirect(Route::url('default'));
}
}
示例15: action_detail
public function action_detail($order_id)
{
$order = Model_Order::find($order_id);
$data['member'] = $order->member;
$data['orders'] = $order;
$data['details'] = $order->orderline;
return View::forge("controlsystem/members/detail", $data);
}