本文整理汇总了PHP中Model_Order::loaded方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_Order::loaded方法的具体用法?PHP Model_Order::loaded怎么用?PHP Model_Order::loaded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model_Order
的用法示例。
在下文中一共展示了Model_Order::loaded方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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'));
}
}
示例2: 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 '';
}
示例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_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'));
}
}
示例5: 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 '';
}
示例6: 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'));
}
}
示例7: 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'));
}
}
示例8: new_order
/**
* [new_order description]
* @param Model_User $user [description]
* @param Model_Product $product [description]
* @param boolean check_match_product, if set to false will update the order with the product if different
* @return [type] [description]
*/
public static function new_order(Model_User $user, Model_Product $product, $match_product = TRUE)
{
$order = new Model_Order();
if ($user->loaded() and $product->loaded()) {
//get if theres an unpaid order for this user we wwill use it..
$order->where('id_user', '=', $user->id_user)->where('status', '=', Model_Order::STATUS_CREATED);
//also check that matches the product for the order
if ($match_product === TRUE) {
$order->where('id_product', '=', $product->id_product)->where('amount', '=', $product->final_price())->where('currency', '=', $product->currency);
}
$order->limit(1)->find();
//order didnt exist so lets create it.
if ($order->loaded() === FALSE) {
//create order
$order = new Model_Order();
$order->id_user = $user->id_user;
}
// no matter what happens if product is different save! this will also save the order if its new ;)
if ($order->id_product != $product->id_product) {
$order->ip_address = ip2long(Request::$client_ip);
$order->id_product = $product->id_product;
$order->currency = $product->currency;
//add coupon ID and discount
if (Model_Coupon::current()->loaded()) {
$order->id_coupon = Model_Coupon::current()->id_coupon;
}
$order->amount = $product->final_price();
$order->VAT = euvat::vat_percentage();
$order->VAT_number = $user->VAT_number;
$order->country = $user->country;
$order->city = $user->city;
$order->postal_code = $user->postal_code;
$order->address = $user->address;
try {
$order->save();
} catch (Exception $e) {
throw HTTP_Exception::factory(500, $e->getMessage());
}
}
}
return $order;
}
示例9: new_order
/**
* creates an order
* @param Model_Ad $ad
* @param Model_User $user
* @param integer $id_product
* @param numeric $amount
* @param string $currency
* @param string $description
* @return Model_Order
*/
public static function new_order(Model_Ad $ad, $user, $id_product, $amount, $currency = NULL, $description = NULL, $featured_days = NULL)
{
if ($currency === NULL) {
$currency = core::config('payment.paypal_currency');
}
if ($description === NULL) {
$description = Model_Order::product_desc($id_product);
}
//get if theres an unpaid order for this product and this ad
$order = new Model_Order();
$order->where('id_ad', '=', $ad->id_ad)->where('id_user', '=', $user->id_user)->where('status', '=', Model_Order::STATUS_CREATED)->where('id_product', '=', $id_product)->where('amount', '=', $amount)->where('currency', '=', $currency)->limit(1)->find();
//if no unpaid create order
if (!$order->loaded()) {
//add coupon ID and discount only if not AD_SELL
if (Model_Coupon::valid($id_product)) {
$amount = Model_Coupon::price($id_product, $amount);
$order->id_coupon = Model_Coupon::current()->id_coupon;
}
//create order
$order = new Model_Order();
$order->id_user = $user->id_user;
$order->id_ad = $ad->id_ad;
$order->id_product = $id_product;
$order->currency = $currency;
$order->amount = $amount;
$order->description = $description;
//store how many days the ad is featured
if ($featured_days !== NULL and is_numeric($featured_days)) {
$order->featured_days = $featured_days;
}
try {
$order->save();
} catch (Exception $e) {
throw HTTP_Exception::factory(500, $e->getMessage());
}
//send email to user with link to pay
$url_checkout = $user->ql('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order));
$replace = array('[ORDER.ID]' => $order->id_order, '[ORDER.DESC]' => $order->description, '[URL.CHECKOUT]' => $url_checkout);
//$user->email('new-order',$replace);
}
return $order;
}
示例10: get_order
/**
* returns and order for the given product, great to check if was paid or not
* @param int $id_product Model_Order::PRODUCT_
* @return boolean/Model_Order false if not found, Model_Order if found
*/
public function get_order($id_product = Model_Order::PRODUCT_CATEGORY)
{
if ($this->loaded()) {
//get if theres an unpaid order for this product and this ad
$order = new Model_Order();
$order->where('id_ad', '=', $this->id_ad)->where('id_user', '=', $this->user->id_user)->where('id_product', '=', $id_product)->limit(1)->find();
return $order->loaded() ? $order : FALSE;
}
return FALSE;
}
示例11: action_order
public function action_order()
{
Breadcrumbs::add(Breadcrumb::factory()->set_title(__('My Purchases'))->set_url(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'orders'))));
Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Order')));
$this->template->title = __('View Order');
$user = Auth::instance()->get_user();
$id_order = $this->request->param('id');
$order = new Model_Order();
$order->where('id_order', '=', $id_order);
//if admin we do not verify the user
if ($user->id_role != Model_Role::ROLE_ADMIN) {
$order->where('id_user', '=', $user->id_user);
}
$order->find();
if (!$order->loaded()) {
Alert::set(ALERT::WARNING, __('Order could not be loaded'));
$this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'orders')));
}
$this->template->bind('content', $content);
$this->template->content = View::factory('oc-panel/profile/order');
$content->order = $order;
$content->product = $order->id_product;
$content->user = $user;
if (core::get('print') == 1) {
$this->template->scripts['footer'] = array('js/oc-panel/order.js');
}
}
示例12: action_checkoutfree
/**
* confirms a checkout when its a free order
* @return [type] [description]
*/
public function action_checkoutfree()
{
$order = new Model_Order($this->request->param('id'));
if ($order->loaded()) {
//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();
//he needs to pay...little prick
if ($order->amount > 0) {
$this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order)));
} else {
$order->confirm_payment('cash');
$this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'orders')));
}
} else {
//throw 404
throw HTTP_Exception::factory(404, __('Page not found'));
}
}
示例13: action_checkout
/**
* pay!
*/
public function action_checkout()
{
if (!Auth::instance()->logged_in()) {
$this->redirect(Route::get('oc-panel')->uri());
}
$user = Auth::instance()->get_user();
//resend confirmation email
if (is_numeric($id_order = $this->request->param('id'))) {
$order = new Model_Order($id_order);
if ($order->loaded() and $order->id_user == $user->id_user and $order->status == Model_Order::STATUS_CREATED) {
//verify the coupon and check order against user information, if its different update order info and maybe price!
$order->check_pricing();
$this->template->title = __('Checkout');
Breadcrumbs::add(Breadcrumb::factory()->set_title($this->template->title));
$this->template->content = View::factory('pages/product/checkout', array('order' => $order, 'user' => $user, 'product' => $order->product));
} else {
Alert::set(Alert::WARNING, __('Order not found or already paid'));
$this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'orders')));
}
} else {
Alert::set(Alert::ERROR, __('Order not found'));
$this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'orders')));
}
}
示例14: action_new
public function action_new()
{
$errors = NULL;
$user = Auth::instance()->get_user();
//create new ticket
if ($_POST) {
//if post save
$id_order = core::post('order');
//check if that order still have support...no cheating!! :D
$order = new Model_Order();
$order->where('id_order', '=', $id_order)->where('id_user', '=', $user->id_user)->where('support_date', '>', Date::unix2mysql())->where('status', '=', Model_Order::STATUS_PAID)->limit(1)->find();
$validation = Validation::factory($this->request->post())->rule('title', 'not_empty')->rule('title', 'min_length', array(':value', 2))->rule('title', 'max_length', array(':value', 145))->rule('description', 'not_empty')->rule('description', 'min_length', array(':value', 50))->rule('description', 'max_length', array(':value', 1000))->rule('order', 'not_empty')->rule('order', 'numeric');
if ($validation->check() and $order->loaded()) {
$ticket = new Model_Ticket();
$ticket->id_user = $user->id_user;
$ticket->id_order = $id_order;
$ticket->id_product = $order->product->id_product;
$ticket->title = core::post('title');
$ticket->description = core::post('description');
$ticket->ip_address = ip2long(Request::$client_ip);
$ticket->save();
//send email to notify_url @todo we should add a config on general to select who gets the emails by default.
if (core::config('email.new_sale_notify')) {
Email::send(core::config('email.notify_email'), '', 'New Ticket: ' . $ticket->title, Route::url('oc-panel', array('controller' => 'support', 'action' => 'ticket', 'id' => $ticket->id_ticket)) . '\\n\\n' . $ticket->description, core::config('email.notify_email'), '');
}
$user->email('new-ticket', array('[TITLE]' => $ticket->title, '[URL.QL]' => $user->ql('oc-panel', array('controller' => 'support', 'action' => 'ticket', 'id' => $ticket->id_ticket))));
Alert::set(Alert::SUCCESS, __('Ticket created.'));
$this->redirect(Route::url('oc-panel', array('controller' => 'support', 'action' => 'index')));
} else {
$errors = $validation->errors('ad');
}
}
Breadcrumbs::add(Breadcrumb::factory()->set_title(__('New Ticket')));
$this->template->title = __('New Ticket');
//get orders with support
$orders = new Model_Order();
$orders = $orders->where('id_user', '=', $user->id_user)->where('support_date', '>', Date::unix2mysql())->where('status', '=', Model_Order::STATUS_PAID)->find_all();
if ($orders->count() == 0) {
Alert::set(Alert::ALERT, __('You do not have any purchase with support active.'));
$this->redirect(Route::url('oc-panel', array('controller' => 'support', 'action' => 'index')));
}
$this->template->bind('content', $content);
$this->template->content = View::factory('oc-panel/pages/support/new', array('orders' => $orders));
$content->errors = $errors;
}
示例15: 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()) {
//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'));
}
//update order based on the price and the amount of
$days = core::get('featured_days');
if (is_numeric($days) and ($price = Model_Order::get_featured_price($days)) !== FALSE) {
$order->amount = $price;
//get price from config
$order->featured_days = $days;
$order->save();
}
//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($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'));
}
}