示例#1
0
 /**
  * Initialize properties before running the controller methods (actions),
  * so they are available to our action.
  */
 public function before($template = NULL)
 {
     parent::before();
     Theme::checker();
     $this->maintenance();
     $this->private_site();
     //get category, deprecated, to keep backwards compatibility with themes
     self::$category = Model_Category::current();
     //Gets a coupon if selected
     self::$coupon = Model_Coupon::current();
     //get the affiliate if any
     Model_Affiliate::current();
     if ($this->auto_render === TRUE) {
         // Load the template
         if ($template !== NULL) {
             $this->template = $template;
         }
         $this->template = View::factory($this->template);
         // Initialize template values
         $this->template->title = core::config('general.site_name');
         $this->template->meta_keywords = '';
         $this->template->meta_description = '';
         $this->template->meta_copyright = 'Open eShop ' . Core::VERSION;
         $this->template->content = '';
         $this->template->styles = array();
         $this->template->scripts = array();
         //we can not cache this view since theres dynamic parts
         //$this->template->header  = View::factory('header');
         //setting inner views try to get from fragment
         // if (Auth::instance()->logged_in())
         //     $this->template->header  = View::fragment('header_front_login','header');
         // else
         $this->template->header = View::factory('header');
         //no fragment since CSRF gets cached :(
         $this->template->footer = View::fragment('footer_front', 'footer');
     }
 }
示例#2
0
 /**
  * ads a new hit in visits DB and counts how many visits has
  * @return integer count
  */
 public function count_hit()
 {
     if (!Model_Visit::is_bot() and $this->loaded() and core::config('product.count_visits') == 1) {
         //adding a visit only if not the owner
         if (!Auth::instance()->logged_in()) {
             $visitor_id = NULL;
         } else {
             $visitor_id = Auth::instance()->get_user()->id_user;
         }
         //adding affiliate if any
         $id_affiliate = NULL;
         if (Model_Affiliate::current()->loaded()) {
             $id_affiliate = Model_Affiliate::current()->id_user;
         }
         //new visit if not owner nad not bot
         if ($this->id_user != $visitor_id) {
             $new_hit = DB::insert('visits', array('id_product', 'id_user', 'id_affiliate', 'ip_address'))->values(array($this->id_product, $visitor_id, $id_affiliate, ip2long(Request::$client_ip)))->execute();
         }
         //count how many visits has
         $hits = new Model_Visit();
         return $hits->where('id_product', '=', $this->id_product)->count_all();
     }
     return 0;
 }
示例#3
0
',
          'price': '<?php 
    echo round($order->product->price, 2);
    ?>
',
          'quantity': 1
        });

        // Transaction level information is provided via an actionFieldObject.
        ga('ec:setAction', 'purchase', {
          'id': '<?php 
    echo $order->id_order;
    ?>
',
          'affiliation': '<?php 
    echo Model_Affiliate::current()->loaded() ? Model_Affiliate::current()->id_user : '';
    ?>
',
          'revenue': '<?php 
    echo round($product_price = 100 * $order->amount / (100 + $order->VAT), 2);
    ?>
',
          'tax': '<?php 
    echo round($order->amount - $product_price, 2);
    ?>
',
          'coupon': '<?php 
    echo is_numeric($order->id_coupon) ? $order->coupon->name : '';
    ?>
'    // User added a coupon at checkout.
        });