Example #1
0
 /**
  * @param $registry Registry
  * @param null|array $c_data
  */
 public function __construct($registry, &$c_data = null)
 {
     $this->registry = $registry;
     $this->cache = $registry->get('cache');
     $this->db = $registry->get('db');
     $this->config = $registry->get('config');
     //if nothing is passed (default) use session array. Customer session, can function on storefrnt only
     if ($c_data == null) {
         $this->cust_data =& $this->session->data;
     } else {
         $this->cust_data =& $c_data;
     }
     if (isset($this->cust_data['country_id']) && isset($this->cust_data['zone_id'])) {
         $country_id = $this->cust_data['country_id'];
         $zone_id = $this->cust_data['zone_id'];
     } else {
         if ($this->config->get('config_tax_store')) {
             $country_id = $this->config->get('config_country_id');
             $zone_id = $this->config->get('config_zone_id');
         } else {
             $country_id = $zone_id = 0;
         }
     }
     $this->setZone($country_id, $zone_id);
 }
 /**
  * @param $registry Registry
  */
 public function __construct($registry)
 {
     $this->db = $registry->get('db');
     $this->config = $registry->get('config');
     $length_class_query = $this->db->query("SELECT *\n\t\t\t\t\t\t\t\t\t\t\t\tFROM " . $this->db->table("length_classes") . " mc\n\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN " . $this->db->table("length_class_descriptions") . " mcd\n\t\t\t\t\t\t\t\t\t\t\t\t\tON (mc.length_class_id = mcd.length_class_id)\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE mcd.language_id = '" . (int) $this->config->get('storefront_language_id') . "'");
     foreach ($length_class_query->rows as $result) {
         $this->lengths[strtolower($result['unit'])] = array('length_class_id' => $result['length_class_id'], 'unit' => $result['unit'], 'title' => $result['title'], 'value' => $result['value']);
     }
 }
Example #3
0
 /**
  * @param $registry Registry
  */
 public function __construct($registry)
 {
     $this->db = $registry->get('db');
     $this->config = $registry->get('config');
     $sql = "SELECT *\n\t\t\t\tFROM " . DB_PREFIX . "weight_classes wc\n\t\t\t\tLEFT JOIN " . DB_PREFIX . "weight_class_descriptions wcd\n\t\t\t\t\tON (wc.weight_class_id = wcd.weight_class_id)\n\t\t\t\tWHERE wcd.language_id = '" . (int) $this->config->get('storefront_language_id') . "'";
     $weight_class_query = $this->db->query($sql);
     foreach ($weight_class_query->rows as $result) {
         $this->weights[strtolower($result['unit'])] = array('weight_class_id' => $result['weight_class_id'], 'title' => $result['title'], 'unit' => $result['unit'], 'value' => $result['value']);
     }
 }
Example #4
0
 /**
  * @param $registry Registry
  */
 public function __construct($registry)
 {
     $this->registry = $registry;
     $this->config = $registry->get('config');
     $this->db = $registry->get('db');
     $this->session = $registry->get('session');
     $this->cache = $registry->get('cache');
     if (isset($this->session->data['country_id']) && isset($this->session->data['zone_id'])) {
         $country_id = $this->session->data['country_id'];
         $zone_id = $this->session->data['zone_id'];
     } else {
         if ($this->config->get('config_tax_store')) {
             $country_id = $this->config->get('config_country_id');
             $zone_id = $this->config->get('config_zone_id');
         } else {
             $country_id = $zone_id = 0;
         }
     }
     $this->setZone($country_id, $zone_id);
 }
 /**
  * Merge cart from session and cart from database content
  * @param array - cart from database
  * @void
  */
 public function mergeCustomerCart($cart)
 {
     $store_id = (int) $this->config->get('config_store_id');
     $cart = !is_array($cart) ? array() : $cart;
     //check is format of cart old or new
     $new = $this->_is_new_cart_format($cart);
     if ($new) {
         $cart = $cart['store_' . $store_id];
     }
     $cart = !is_array($cart) ? array() : $cart;
     // for case when data format is new but cart for store does not yet created
     foreach ($cart as $key => $value) {
         if (!array_key_exists($key, $this->session->data['cart'])) {
             $this->session->data['cart'][$key] = $value;
         }
     }
 }
/**
 * @param AConfig $config
 */
function grantStripeAccess($config)
{
    if ($config->get('default_stripe_access_token')) {
        Stripe::setApiKey($config->get('default_stripe_access_token'));
    } else {
        if ($config->get('default_stripe_test_mode')) {
            Stripe::setApiKey($config->get('default_stripe_sk_test'));
        } else {
            Stripe::setApiKey($config->get('default_stripe_sk_live'));
        }
    }
}
Example #7
0
 /**
  * @param string $loginname
  * @param string $password
  * @return bool
  */
 public function login($loginname, $password)
 {
     $approved_only = '';
     if ($this->config->get('config_customer_approval')) {
         $approved_only = " AND approved = '1'";
     }
     $customer_query = $this->db->query("SELECT *\n\t\t\t\t\t\t\t\t\t\t\tFROM " . $this->db->table("customers") . "\n\t\t\t\t\t\t\t\t\t\t\tWHERE loginname = '" . $this->db->escape($loginname) . "'\n\t\t\t\t\t\t\t\t\t\t\tAND password = '******'\n\t\t\t\t\t\t\t\t\t\t\tAND status = '1'" . $approved_only);
     if ($customer_query->num_rows) {
         $this->session->data['customer_id'] = $customer_query->row['customer_id'];
         if ($customer_query->row['cart'] && is_string($customer_query->row['cart'])) {
             $cart = unserialize($customer_query->row['cart']);
             foreach ($cart as $key => $value) {
                 if (!array_key_exists($key, $this->session->data['cart'])) {
                     $this->session->data['cart'][$key] = $value;
                 } else {
                     $this->session->data['cart'][$key]['qty'] += $value['qty'];
                 }
             }
         }
         $this->loginname = $loginname;
         $this->customer_id = $customer_query->row['customer_id'];
         $this->firstname = $customer_query->row['firstname'];
         $this->lastname = $customer_query->row['lastname'];
         if ($this->dcrypt->active) {
             $this->email = $this->dcrypt->decrypt_field($customer_query->row['email'], $customer_query->row['key_id']);
             $this->telephone = $this->dcrypt->decrypt_field($customer_query->row['telephone'], $customer_query->row['key_id']);
             $this->fax = $this->dcrypt->decrypt_field($customer_query->row['fax'], $customer_query->row['key_id']);
         } else {
             $this->email = $customer_query->row['email'];
             $this->telephone = $customer_query->row['telephone'];
             $this->fax = $customer_query->row['fax'];
         }
         $this->newsletter = $customer_query->row['newsletter'];
         $this->customer_group_id = $customer_query->row['customer_group_id'];
         $this->address_id = $customer_query->row['address_id'];
         $this->cache->delete('storefront_menu');
         return TRUE;
     } else {
         return FALSE;
     }
 }