Beispiel #1
0
 function show()
 {
     $user = hikashop_loadUser(true);
     $userClass = hikashop_get('class.user');
     $userClass->loadPartnerData($user);
     $config =& hikashop_config();
     if (empty($user->user_params->user_custom_fee)) {
         $user->user_params->user_partner_click_fee = $config->get('partner_click_fee', 0);
         $user->user_params->user_partner_lead_fee = $config->get('partner_lead_fee', 0);
         $user->user_params->user_partner_percent_fee = $config->get('partner_percent_fee', 0);
         $user->user_params->user_partner_flat_fee = $config->get('partner_flat_fee', 0);
     }
     $query = 'SELECT * FROM ' . hikashop_table('banner') . ' WHERE banner_published=1 ORDER BY banner_ordering ASC;';
     $database = JFactory::getDBO();
     $database->setQuery($query);
     $banners = $database->loadObjectList();
     $this->assignRef('banners', $banners);
     $advanced_stats = $config->get('affiliate_advanced_stats', 1);
     $this->assignRef('advanced_stats', $advanced_stats);
     $this->assignRef('user', $user);
     $currencyType = hikashop_get('type.currency');
     $this->assignRef('currencyType', $currencyType);
     $currencyHelper = hikashop_get('class.currency');
     $this->assignRef('currencyHelper', $currencyHelper);
     $popup = hikashop_get('helper.popup');
     $this->assignRef('popup', $popup);
     JHTML::_('behavior.tooltip');
     $affiliate_plugin = hikashop_import('system', 'hikashopaffiliate');
     $partner_id = (int) @$user->user_id;
     $this->assignRef('partner_id', $partner_id);
     $partner_info = $affiliate_plugin->params->get('partner_key_name', 'partner_id') . '=' . $partner_id;
     $this->assignRef('partner_info', $partner_info);
     $allow_currency_selection = $config->get('allow_currency_selection');
     $this->assignRef('allow_currency_selection', $allow_currency_selection);
     if (empty($this->user->user_id)) {
         $app = JFactory::getApplication();
         global $Itemid;
         $url = '';
         if (!empty($Itemid)) {
             $url = '&Itemid=' . $Itemid;
         }
         if (!HIKASHOP_J16) {
             $url = 'index.php?option=com_user&view=login' . $url;
         } else {
             $url = 'index.php?option=com_users&view=login' . $url;
         }
         $url = JRoute::_($url . '&return=' . urlencode(base64_encode(hikashop_currentUrl('', false))));
         $app->enqueueMessage('<a href="' . $url . '">' . JText::_('PLEASE_LOGIN_FIRST') . '</a>');
     }
     $config =& hikashop_config();
     $affiliate_terms = $config->get('affiliate_terms', 0);
     $this->assignRef('affiliate_terms', $affiliate_terms);
     hikashop_setPageTitle('AFFILIATE');
 }
Beispiel #2
0
 function listing()
 {
     $user = JFactory::getUser();
     if ($user->guest) {
         $app = JFactory::getApplication();
         $app->enqueueMessage(JText::_('PLEASE_LOGIN_FIRST'));
         global $Itemid;
         $url = '';
         if (!empty($Itemid)) {
             $url = '&Itemid=' . $Itemid;
         }
         if (version_compare(JVERSION, '1.6', '<')) {
             $url = 'index.php?option=com_user&view=login' . $url;
         } else {
             $url = 'index.php?option=com_users&view=login' . $url;
         }
         $app->redirect(JRoute::_($url . '&return=' . urlencode(base64_encode(hikashop_currentUrl('', false))), false));
         return false;
     }
     return parent::listing();
 }
Beispiel #3
0
}
?>
<tr class="hikashop_registration_required_info_line">
	<td colspan="2" height="40">
		<?php 
echo JText::_('HIKA_REGISTER_REQUIRED');
?>
	</td>
</tr>
</table>
<input type="hidden" name="data[register][id]" value="<?php 
echo (int) $this->mainUser->get('id');
?>
" />
<input type="hidden" name="data[register][gid]" value="<?php 
echo (int) $this->mainUser->get('gid');
?>
" />
<?php 
if (empty($this->form_name)) {
    $this->form_name = 'hikashop_checkout_form';
}
$registerButtonName = JText::_('HIKA_REGISTER');
if ($this->simplified_registration == 2) {
    $registerButtonName = JText::_('HIKA_NEXT');
}
echo $this->cartClass->displayButton($registerButtonName, 'register', $this->params, hikashop_currentUrl(), ' hikashopSubmitForm(\'' . $this->form_name . '\'); return false;', 'id="hikashop_register_form_button"');
$button = $this->config->get('button_style', 'normal');
if ($button == 'css') {
    echo '<input type="submit" style="position: absolute; left: -9999px; width: 1px; height: 1px;"/></input>';
}
Beispiel #4
0
 function prepareFields(&$fields, &$data, $type = 'user', $url = 'checkout&task=state', $test = false)
 {
     if (empty($fields)) {
         return;
     }
     $id = $type . '_id';
     switch ($type) {
         case 'address':
             $user_id = (int) @$data->address_user_id;
             break;
         case 'item':
             $order_id = (int) @$data->order_id;
             if ($order_id > 0) {
                 $orderClass = hikashop_get('class.order');
                 $order = $orderClass->get($order_id);
                 $user_id = (int) @$order->order_user_id;
             } else {
                 $user_id = 0;
             }
             break;
         case 'order':
             $user_id = (int) @$data->order_user_id;
             break;
         default:
             $user_id = 0;
             break;
     }
     $guest = true;
     if ($user_id > 0) {
         $userClass = hikashop_get('class.user');
         $user = $userClass->get($user_id);
         $guest = !(bool) @$user->user_cms_id;
     }
     foreach ($fields as $namekey => $field) {
         $fields[$namekey]->guest_mode = $guest;
         if (!empty($fields[$namekey]->field_options) && is_string($fields[$namekey]->field_options)) {
             $fields[$namekey]->field_options = unserialize($fields[$namekey]->field_options);
         }
         if (!empty($field->field_value) && is_string($fields[$namekey]->field_value)) {
             $fields[$namekey]->field_value = $this->explodeValues($fields[$namekey]->field_value);
         }
         if (is_object($data) && empty($data->{$id}) && !empty($namekey) && empty($data->{$namekey})) {
             if ($data == null || empty($data)) {
                 $data = new stdClass();
             }
             if (empty($fields[$namekey]->field_options['pleaseselect'])) {
                 $data->{$namekey} = $field->field_default;
             } else {
                 $data->{$namekey} = '';
             }
         } else {
             if (is_array($data) && !empty($namekey)) {
                 $v = empty($fields[$namekey]->field_options['pleaseselect']) ? $field->field_default : '';
                 foreach ($data as &$d) {
                     if (!empty($d->{$namekey}) || !empty($data->{$id})) {
                         continue;
                     }
                     $d->{$namekey} = $v;
                 }
             }
         }
         if (!empty($fields[$namekey]->field_options['zone_type']) && $fields[$namekey]->field_options['zone_type'] == 'country') {
             $baseUrl = JURI::base() . 'index.php?option=com_hikashop&ctrl=' . $url . '&tmpl=component';
             $currentUrl = strtolower(hikashop_currentUrl());
             if (substr($currentUrl, 0, 8) == 'https://') {
                 $domain = substr($currentUrl, 0, strpos($currentUrl, '/', 9));
             } else {
                 $domain = substr($currentUrl, 0, strpos($currentUrl, '/', 8));
             }
             if (substr($baseUrl, 0, 8) == 'https://') {
                 $baseUrl = $domain . substr($baseUrl, strpos($baseUrl, '/', 9));
             } else {
                 $baseUrl = $domain . substr($baseUrl, strpos($baseUrl, '/', 8));
             }
             $fields[$namekey]->field_url = $baseUrl . '&';
         }
     }
     $this->handleZone($fields, $test, $data);
 }
Beispiel #5
0
 function showcarts()
 {
     $app = JFactory::getApplication();
     $config = hikashop_config();
     $menus = $app->getMenu();
     $menu = $menus->getActive();
     global $Itemid;
     if (empty($menu)) {
         if (!empty($Itemid)) {
             $menus->setActive($Itemid);
             $menu = $menus->getItem($Itemid);
         }
     }
     if (is_object($menu) && is_object($menu->params)) {
         $cart_type = $menu->params->get('cart_type');
     }
     if (!empty($cart_type)) {
         JRequest::setVar('cart_type', $cart_type);
     } else {
         $cart_type = JRequest::getString('cart_type', 'cart');
         if (!in_array($cart_type, array('cart', 'wishlist'))) {
             $cart_type = 'cart';
         }
     }
     $this->assignRef('cart_type', $cart_type);
     $pageInfo = new stdClass();
     $pageInfo->filter = new stdClass();
     $pageInfo->filter->order = new stdClass();
     $pageInfo->limit = new stdClass();
     $pageInfo->filter->order->value = $app->getUserStateFromRequest($this->paramBase . ".filter_order", 'filter_order', 'a.cart_id', 'cmd');
     $pageInfo->filter->order->dir = $app->getUserStateFromRequest($this->paramBase . ".filter_order_Dir", 'filter_order_Dir', 'desc', 'word');
     $pageInfo->search = $app->getUserStateFromRequest($this->paramBase . ".search", 'search', '', 'string');
     $pageInfo->search = JString::strtolower(trim($pageInfo->search));
     $pageInfo->limit->start = $app->getUserStateFromRequest($this->paramBase . '.limitstart', 'limitstart', 0, 'int');
     $oldValue = $app->getUserState($this->paramBase . '.list_limit');
     if (empty($oldValue)) {
         $oldValue = $app->getCfg('list_limit');
     }
     $pageInfo->limit->value = $app->getUserStateFromRequest($this->paramBase . '.list_limit', 'limit', $app->getCfg('list_limit'), 'int');
     if ($oldValue != $pageInfo->limit->value) {
         $pageInfo->limit->start = 0;
         $app->setUserState($this->paramBase . '.limitstart', 0);
     }
     $database = JFactory::getDBO();
     $searchMap = array('a.cart_id', 'a.cart_name', 'a.cart_type');
     if (hikashop_loadUser() == null) {
         global $Itemid;
         $url = '';
         if (!empty($Itemid)) {
             $url = '&Itemid=' . $Itemid;
         }
         if (!HIKASHOP_J16) {
             $url = 'index.php?option=com_user&view=login' . $url;
         } else {
             $url = 'index.php?option=com_users&view=login' . $url;
         }
         if ($config->get('enable_multicart', '0')) {
             $app->redirect(JRoute::_($url . '&return=' . urlencode(base64_encode(hikashop_currentUrl('', false))), false));
         } else {
             $app->redirect(JRoute::_($url . '&return=' . base64_encode(hikashop_completeLink('cart&task=showcart&cart_type=' . $cart_type . '&Itemid=' . $Itemid, false, false, true)), false));
         }
         return false;
     }
     $user = hikashop_loadUser(true);
     if (isset($user->user_cms_id)) {
         $user->id = $user->user_cms_id;
     } else {
         if (empty($user)) {
             $user = new stdClass();
         }
         $user->id = 0;
     }
     $session = JFactory::getSession();
     if ($session->getId()) {
         $user->session = $session->getId();
     } else {
         $user->session = '';
     }
     if (hikashop_loadUser() == null) {
         $filters = array('a.session_id=' . $database->Quote($user->session) . ' AND a.cart_type =' . $database->quote($cart_type));
     } else {
         $filters = array('(a.user_id=' . (int) $user->id . ' OR a.session_id=' . $database->Quote($user->session) . ') AND a.cart_type =' . $database->quote($cart_type));
     }
     $groupBy = 'GROUP BY a.cart_id';
     $order = '';
     if (!empty($pageInfo->filter->order->value)) {
         $order = 'ORDER BY a.cart_id ASC';
     }
     if (!empty($pageInfo->search)) {
         $searchVal = '\'%' . hikashop_getEscaped(JString::strtolower(trim($pageInfo->search)), true) . '%\'';
         $filter = implode(" LIKE {$searchVal} OR ", $searchMap) . " LIKE {$searchVal}";
         $filters[] = $filter;
     }
     $from = 'FROM ' . hikashop_table('cart') . ' AS a';
     $cartProduct = 'LEFT JOIN ' . hikashop_table('cart_product') . ' AS b ON a.cart_id=b.cart_id';
     $where = 'WHERE (' . implode(') AND (', $filters) . ') AND a.cart_type =' . $database->quote($cart_type);
     $query = $from . ' ' . $where . ' ' . $groupBy . ' ' . $order;
     //'.$cartProduct.'
     $database->setQuery('SELECT a.* ' . $query);
     $rows = $database->loadObjectList();
     $database->setQuery('SELECT COUNT(*) ' . $from . ' ' . $where);
     $currencyClass = hikashop_get('class.currency');
     $this->assignRef('currencyHelper', $currencyClass);
     $module = hikashop_get('helper.module');
     $module->initialize($this);
     $currencyClass = hikashop_get('class.currency');
     $class = hikashop_get('class.cart');
     $productClass = hikashop_get('class.product');
     $main_currency = (int) $config->get('main_currency', 1);
     $currency_id = hikashop_getCurrency();
     if ($config->get('tax_zone_type', 'shipping') == 'billing') {
         $zone_id = hikashop_getZone('billing');
     } else {
         $zone_id = hikashop_getZone('shipping');
     }
     $discount_before_tax = (int) $config->get('discount_before_tax', 0);
     $cids = array();
     foreach ($rows as $row) {
         if ($row->cart_id != null) {
             $cids[] = $row->cart_id;
         }
     }
     $filters = '';
     $filters = array('a.cart_id IN(' . implode(",", $cids) . ')');
     $order = '';
     if (!empty($pageInfo->filter->order->value)) {
         $order = ' ORDER BY cart_id ASC';
     }
     $product = ' LEFT JOIN ' . hikashop_table('product') . ' AS b ON a.product_id=b.product_id';
     $query = 'FROM ' . hikashop_table('cart_product') . ' AS a ' . $product . ' WHERE (' . implode(') AND (', $filters) . ') ' . $order;
     $database->setQuery('SELECT a.*,b.* ' . $query);
     if (!empty($cids)) {
         $products = $database->loadObjectList();
         $ids = array();
         foreach ($products as $row) {
             $ids[] = $row->product_id;
         }
         $row_1 = 0;
         foreach ($products as $k => $row) {
             $currencyClass->getPrices($row, $ids, $currency_id, $main_currency, $zone_id, $discount_before_tax);
             if (!isset($row->prices[0]->price_value)) {
                 if (isset($row_1->prices[0])) {
                     $row->prices[0] = $row_1->prices[0];
                 }
             }
             $products[$k]->hide = 0;
             if ($row->product_type == 'variant') {
                 $l = --$k;
                 if (isset($products[$l])) {
                     if (!isset($products[$l]) || !is_object($products[$l])) {
                         $products[$l] = new stdClass();
                     }
                     $products[$l]->hide = 1;
                 }
             }
             $row_1 = $row;
         }
         $currentId = 0;
         $values = null;
         $price = 0;
         $price_with_tax = 0;
         $quantity = 0;
         $currency = hikashop_getCurrency();
         foreach ($products as $product) {
             if (isset($product->cart_id) && isset($product->product_id)) {
                 if ($product->cart_id != $currentId) {
                     $price = 0;
                     $price_with_tax = 0;
                     $quantity = 0;
                     $currentId = $product->cart_id;
                     if (isset($product->prices[0]->price_currency_id)) {
                         $currency = $product->prices[0]->price_currency_id;
                     }
                 }
                 if (isset($product->prices[0])) {
                     $price += $product->cart_product_quantity * $product->prices[0]->price_value;
                 }
                 if (isset($product->prices[0]->price_value_with_tax)) {
                     $price_with_tax += $product->cart_product_quantity * $product->prices[0]->price_value_with_tax;
                 }
                 if (!isset($product->prices[0]->price_value)) {
                     $variant = new stdClass();
                     $variant->product_parent_id = $product->product_parent_id;
                     $variant->quantity = $product->cart_product_quantity;
                 }
                 if (isset($variant) && isset($product->prices[0]) && $product->product_id == $variant->product_parent_id) {
                     $price += $variant->quantity * $product->prices[0]->price_value;
                     $price_with_tax += $variant->quantity * $product->prices[0]->price_value_with_tax;
                 }
                 $quantity += $product->cart_product_quantity;
                 if (!isset($values[$currentId])) {
                     $values[$currentId] = new stdClass();
                 }
                 $values[$currentId]->price = $price;
                 $values[$currentId]->price_with_tax = isset($price_with_tax) ? $price_with_tax : $price;
                 $values[$currentId]->quantity = $quantity;
                 $values[$currentId]->currency = $currency;
             }
         }
         $totalCart = 0;
         $limit = 0;
         foreach ($rows as $k => $row) {
             if ($limit >= (int) $pageInfo->limit->start && $limit < (int) $pageInfo->limit->value && isset($values[$row->cart_id]) && $values[$row->cart_id] != null) {
                 $rows[$k]->price = $values[$row->cart_id]->price;
                 $rows[$k]->price_with_tax = $values[$row->cart_id]->price_with_tax;
                 $rows[$k]->quantity = $values[$row->cart_id]->quantity;
                 $rows[$k]->currency = $values[$row->cart_id]->currency;
                 $totalCart++;
             } else {
                 unset($rows[$k]);
                 $limit--;
             }
             $limit++;
         }
     }
     $pageInfo->elements = new stdClass();
     $pageInfo->elements->total = count($rows);
     if (!empty($pageInfo->search)) {
         $rows = hikashop_search($pageInfo->search, $rows, 'cart_id');
     }
     $pageInfo->elements->page = count($rows);
     if (!$pageInfo->elements->page) {
         if (hikashop_loadUser() != null) {
             $app = JFactory::getApplication();
             if ($cart_type == 'cart') {
                 $app->enqueueMessage(JText::_('HIKA_NO_CARTS_FOUND'));
             } else {
                 $app->enqueueMessage(JText::_('HIKA_NO_WISHLISTS_FOUND'));
             }
         }
     }
     jimport('joomla.html.pagination');
     $pagination = hikashop_get('helper.pagination', $pageInfo->elements->total, $pageInfo->limit->start, $pageInfo->limit->value);
     $pagination->hikaSuffix = '';
     $this->assignRef('pagination', $pagination);
     $this->assignRef('pageInfo', $pageInfo);
     $cart = hikashop_get('helper.cart');
     $this->assignRef('cart', $cart);
     $this->assignRef('config', $config);
     $this->assignRef('carts', $rows);
     if ($cart_type == 'cart') {
         $title = JText::_('CARTS');
     } else {
         $title = JText::_('WISHLISTS');
     }
     hikashop_setPageTitle($title);
 }
Beispiel #6
0
    function googleGetJS($accounts, &$order, $currencyInfo)
    {
        $found = false;
        $app = JFactory::getApplication();
        foreach ($accounts as $acc) {
            if ($acc->currency == $currencyInfo->currency_code && !empty($acc->account_id)) {
                $account = $acc->account_id;
                $found = true;
                if (!preg_match('/UA-[0-9]{2,12}-[0-9]{1}/', $account)) {
                    if (!$app->getUserState(HIKASHOP_COMPONENT . '.error_display_ga')) {
                        $app->setUserState(HIKASHOP_COMPONENT . '.error_display_ga', 1);
                        $app->enqueueMessage(JText::_('GOOGLE_ACCOUNT_ID_INVALID'));
                        $app->redirect(hikashop_currentUrl('', false));
                    }
                    return '';
                }
                break;
            }
        }
        if (!$found) {
            if (!$app->getUserState(HIKASHOP_COMPONENT . '.error_display_ga')) {
                $app->setUserState(HIKASHOP_COMPONENT . '.error_display_ga', 1);
                $app->enqueueMessage(JText::_('NO_CURRENCY_FOUND_GOOGLE_ANALYTICS'));
                $app->redirect(hikashop_currentUrl('', false));
            }
            return '';
        }
        $jconf = JFactory::getConfig();
        if (HIKASHOP_J30) {
            $siteName = $jconf->get('sitename');
        } else {
            $siteName = $jconf->getValue('config.sitename');
        }
        $tax = $order->order_subtotal_no_vat + $order->order_shipping_tax + $order->order_discount_tax;
        if ($this->params->get('use_universal', 0)) {
            $extra_required = '';
            if ($this->params->get('module_displayfeatures', 0)) {
                $extra_required .= "\r\n" . 'ga("require", "displayfeatures");';
            }
            if ($this->params->get('module_linkid', 0)) {
                $extra_required .= "\r\n" . 'ga("require", "linkid", "linkid.js");';
            }
            $js = '
<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,"script","//www.google-analytics.com/analytics.js","ga");

ga("create", "' . $account . '", "auto");
ga("send", "pageview");' . $extra_required . '
ga("require", "ecommerce", "ecommerce.js");

ga("ecommerce:addTransaction", {
	"id": "' . $order->order_id . '",
	"affiliation": "' . str_replace(array('\\', '"'), array('\\\\', '\\\\"'), $siteName) . '",
	"revenue": "' . round($order->order_full_price, 2) . '",
	"shipping": "' . round($order->order_shipping_price, 2) . '",
	"tax": "' . round($tax, 2) . '"
});
';
            foreach ($order->products as $product) {
                $js .= '
ga("ecommerce:addItem", {
	"id": "' . $order->order_id . '",
	"name": "' . str_replace(array('\\', '"'), array('\\\\', '\\\\"'), strip_tags($product->order_product_name)) . '",
	"sku": "' . str_replace(array('\\', '"'), array('\\\\', '\\\\"'), $product->order_product_code) . '",
	"category": "",
	"price": "' . ($product->order_product_price + $product->order_product_tax) . '",
	"quantity": "' . (int) $product->order_product_quantity . '"
});
';
            }
            $js .= '
ga("ecommerce:send");
</script>
<!-- End Google Analytics -->
';
            if ($this->params->get('debug_mode')) {
                $ip = hikashop_getIP();
                $data = 'Adding google UA javascript' . "\r\n" . 'IP: ' . $ip . "\r\n" . 'URL: ' . hikashop_currentURL() . "\r\n\r\n" . '<pre>' . htmlentities($js) . '</pre>';
                $this->writeToLog($data);
            }
        } else {
            $extra_required = '';
            if ($this->params->get('module_linkid', 0)) {
                $extra_required .= "\r\n" . 'var pluginUrl = "//www.google-analytics.com/plugins/ga/inpage_linkid.js";
_gaq.push(["_require", "inpage_linkid", pluginUrl]);';
            }
            $js = '
<script type="text/javascript">
var _gaq = _gaq || [];' . $extra_required . '
_gaq.push(["_setAccount", "' . $account . '"]);
_gaq.push(["_trackPageview"]);
_gaq.push(["_addTrans",
	"' . $order->order_id . '",
	"' . str_replace(array('\\', '"'), array('\\\\', '\\\\"'), $siteName) . '",
	"' . round($order->order_full_price, 2) . '",
	"' . $tax . '",
	"' . round($order->order_shipping_price, 2) . '",
	"' . str_replace(array('\\', '"'), array('\\\\', '\\\\"'), @$order->billing_address->address_city) . '",
	"' . str_replace(array('\\', '"'), array('\\\\', '\\\\"'), @$order->billing_address->address_state) . '",
	"' . str_replace(array('\\', '"'), array('\\\\', '\\\\"'), @$order->billing_address->address_country) . '",
]);
';
            foreach ($order->products as $product) {
                $js .= '
_gaq.push(["_addItem",
	"' . $order->order_id . '",
	"' . str_replace(array('\\', '"'), array('\\\\', '\\\\"'), $product->order_product_code) . '",
	"' . str_replace(array('\\', '"'), array('\\\\', '\\\\"'), strip_tags($product->order_product_name)) . '",
	"",
	"' . ($product->order_product_price + $product->order_product_tax) . '",
	"' . $product->order_product_quantity . '"
]);
';
            }
            $file = 'ga.js';
            if ($this->params->get('debug_mode')) {
                $file = 'u/ga_debug.js';
            }
            $js .= '
_gaq.push(["_trackTrans"]);
(function() {
	var ga = document.createElement("script"); ga.type = "text/javascript"; ga.async = true;
	ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/' . $file . '";
	var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
';
        }
        return $js;
    }