当前位置: 首页>>代码示例>>PHP>>正文


PHP Model_Base::check_logged方法代码示例

本文整理汇总了PHP中Model_Base::check_logged方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_Base::check_logged方法的具体用法?PHP Model_Base::check_logged怎么用?PHP Model_Base::check_logged使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Model_Base的用法示例。


在下文中一共展示了Model_Base::check_logged方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: shipping_price

 /**
  * Calculate order shipping price
  * 
  * @param type $postcode    = Postcode to calculate price
  * @param type $default     = Default return value if postcode dont exist or not set
  * @param type $default     = 
  * @return type
  */
 public function shipping_price($postcode = null, $default = null, $force_current_user = false)
 {
     // Default postcode to users postcode
     if (is_null($postcode)) {
         if ($force_current_user) {
             if (\Model_Base::check_logged()) {
                 $user = \Sentry::user();
                 $postcode = $user->get('metadata.postcode');
             }
         } else {
             $postcode = $this->user->get('metadata.postcode');
         }
     }
     // Load shipping configuration
     \Config::load('product::shipping', 'shipping', true);
     $prices = \Arr::sort(\Config::get('shipping.price', array()), 'from');
     if (!is_numeric($default)) {
         $default = \Config::get('shipping.default', 0);
     }
     $target_price = $default;
     // If we dont have postcode we return zero shipping price
     if (!$postcode || !is_numeric($postcode)) {
         return $target_price;
     }
     // Find coresponding price for this postcode
     foreach ($prices as $price) {
         if ($price['from'] <= $postcode && $price['to'] >= $postcode) {
             $target_price = $price['price'];
             break;
         }
     }
     // return $target_price;
     // no shipping price for enviroform site
     return $default;
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:43,代码来源:order.php

示例2: filter_by_group

 public static function filter_by_group()
 {
     $out['assigned'] = array();
     $out['not_assigned'] = array();
     $products_assigned = array();
     $products_not_assigned = array();
     $in_groups = array();
     $not_in_groups = array();
     if (parent::check_logged()) {
         $groups = Model_Group_Options::find(array(), 'product_group_id');
         $user = \Sentry::user();
         $user_group = $user->groups();
         $user_group = $user_group[0];
         if (isset($user_group['id'])) {
             $in_groups = Model_Group_Options::find(array('where' => array('user_group_id' => $user_group['id'], 'able_to_buy' => 1)), 'product_group_id');
             $not_in_groups = Model_Group_Options::find(array('where' => array(array('user_group_id', '!=', $user_group['id']))), 'product_group_id');
             if (!is_array($in_groups)) {
                 $in_groups = array();
             }
             if (!is_array($not_in_groups)) {
                 $not_in_groups = array();
             }
             $not_in_groups = array_diff_key($not_in_groups, $in_groups);
         }
     } else {
         $not_in_groups = Model_Group_Options::find(array(), 'product_group_id');
     }
     if (!empty($in_groups)) {
         $groups = '(' . implode(',', array_keys($in_groups)) . ')';
         $products_assigned = Model_Product_To_Groups::find(function ($query) use($groups) {
             $query->where('group_id', 'IN', \DB::expr($groups));
             return $query;
         }, 'product_id');
     }
     if (!empty($not_in_groups)) {
         $groups = '(' . implode(',', array_keys($not_in_groups)) . ')';
         $products_not_assigned = Model_Product_To_Groups::find(function ($query) use($groups) {
             $query->where('group_id', 'IN', \DB::expr($groups));
             return $query;
         }, 'product_id');
     }
     $out['assigned'] = $products_assigned;
     $out['not_assigned'] = $products_not_assigned;
     return $out;
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:45,代码来源:product.php


注:本文中的Model_Base::check_logged方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。