Skip to content

Commit 407c0dc

Browse files
author
stubbe-dev
committed
updates to module for new release
1 parent b012e87 commit 407c0dc

File tree

107 files changed

+4604
-258
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+4604
-258
lines changed

code/Block/Adminhtml/Dashboard.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ protected function getWebsite()
7878
*/
7979
public function getStoreId()
8080
{
81-
return $this->getRequest()->getParam('store');
81+
return $this->getRequest()->getParam('store') ? $this->getRequest()->getParam('store') : Mage::app()->getDefaultStoreView()->getId();
8282
}
8383

8484
/**

code/Block/Adminhtml/System/Config/Form/AttributeLabels.php

+10-5
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
1717

1818
$values = json_decode($element->getValue(), true);
1919

20-
21-
22-
foreach (explode(',', $attributes) as $attribute) {
20+
foreach ($attributes as $attribute) {
2321
$attribute = str_replace(' ','',$attribute);
2422

2523
$value = isset($values[$attribute]) ? $values[$attribute] : ['label' => $attribute, 'sort_order'=> 0];
@@ -45,12 +43,19 @@ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
4543
/**
4644
* Get configured facet attributes
4745
*
48-
* @return mixed
46+
* @return array
4947
* @throws Mage_Core_Model_Store_Exception
5048
*/
5149
protected function getConfiguredAttributes()
5250
{
53-
return Mage::getStoreConfig(Clerk_Clerk_Model_Config::XML_PATH_FACETED_SEARCH_ATTRIBUTES, $this->getStore());
51+
$rawConfiguredAttributes = Mage::getStoreConfig(
52+
Clerk_Clerk_Model_Config::XML_PATH_FACETED_SEARCH_ATTRIBUTES,
53+
$this->getStore()
54+
);
55+
if (empty($rawConfiguredAttributes)) {
56+
return [];
57+
}
58+
return array_map('trim', explode(',', $rawConfiguredAttributes));
5459
}
5560

5661
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<?php
2+
3+
class Clerk_Clerk_Block_SalesTracking extends Mage_Core_Block_Template
4+
{
5+
/**
6+
* @var Mage_Sales_Model_Order
7+
*/
8+
protected $_order;
9+
10+
const XML_PATH_PUBLIC_KEY = 'clerk/general/publicapikey';
11+
12+
/**
13+
* Get public key
14+
*
15+
* @return mixed
16+
*/
17+
public function getPublicKey()
18+
{
19+
return Mage::getStoreConfig(self::XML_PATH_PUBLIC_KEY);
20+
}
21+
22+
/**
23+
* Get order increment id
24+
*
25+
* @return string
26+
*/
27+
public function getIncrementId()
28+
{
29+
return $this->_getOrder()->getIncrementId();
30+
}
31+
32+
/**
33+
* Get customer id
34+
*
35+
* @return int
36+
*/
37+
public function getCustomerId()
38+
{
39+
return $this->_getOrder()->getCustomerId();
40+
}
41+
42+
/**
43+
* @return bool
44+
*/
45+
public function getShouldTrack() {
46+
47+
$Dont_Track = [''];
48+
49+
$OrderStatus = $this->_getOrder()->getStatus();
50+
51+
if (!in_array($OrderStatus, $Dont_Track)) {
52+
53+
return true;
54+
55+
}
56+
57+
return false;
58+
59+
}
60+
61+
/**
62+
* Get customer email
63+
*
64+
* @return string
65+
*/
66+
public function getCustomerEmail()
67+
{
68+
return $this->_getOrder()->getCustomerEmail();
69+
}
70+
71+
/**
72+
* Get order products as json
73+
*
74+
* @return string
75+
*/
76+
public function getProducts()
77+
{
78+
$order = $this->_getOrder();
79+
$products = [];
80+
81+
foreach ($order->getAllVisibleItems() as $item) {
82+
/** @var Mage_Sales_Model_Order_Item $item */
83+
$products[] = [
84+
'id' => $item->getProductId(),
85+
'quantity' => (int) $item->getQtyOrdered(),
86+
'price' => $item->getBasePriceInclTax(),
87+
];
88+
}
89+
90+
return json_encode($products);
91+
}
92+
93+
/**
94+
* Get last order
95+
*
96+
* @return Mage_Sales_Model_Order
97+
*/
98+
protected function _getOrder()
99+
{
100+
if (!$this->_order) {
101+
$incrementId = $this->_getCheckout()->getLastRealOrderId();
102+
$this->_order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
103+
}
104+
105+
return $this->_order;
106+
}
107+
108+
/**
109+
* Get checkout session
110+
*
111+
* @return Mage_Checkout_Model_Session|Mage_Core_Model_Abstract
112+
*/
113+
protected function _getCheckout()
114+
{
115+
return Mage::getSingleton('checkout/session');
116+
}
117+
}

code/Block/Widget/Content.php

+60-4
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,20 @@ protected function _toHtml()
3737
*/
3838
public function getSpanAttributes()
3939
{
40+
41+
//$filter_powerstep = Mage::getStoreConfigFlag('clerk/powerstep/exclude_duplicates_powerstep');
42+
$filter_category = Mage::getStoreConfigFlag('clerk/category/exclude_duplicates_category');
43+
$filter_product = Mage::getStoreConfigFlag('clerk/product/exclude_duplicates_product');
44+
$filter_cart = Mage::getStoreConfigFlag('clerk/cart/exclude_duplicates_cart');
45+
46+
static $product_contents = 0;
47+
static $cart_contents = 0;
48+
static $category_contents = 0;
49+
4050
$output = '';
4151
$spanAttributes = [
4252
'class' => 'clerk',
43-
'data-template' => '@' . $this->getContent(),
53+
'data-template' => '@' . $this->getContent()
4454
];
4555

4656
if ($this->getProductId()) {
@@ -53,6 +63,20 @@ public function getSpanAttributes()
5363

5464
if ($productId) {
5565
$spanAttributes['data-products'] = json_encode([$productId]);
66+
if($filter_product){
67+
$unique_class = "clerk_" . (string)$product_contents;
68+
$spanAttributes['class'] = 'clerk ' . $unique_class;
69+
if($product_contents > 0){
70+
$filter_string = '';
71+
for($i = 0; $i < $product_contents; $i++){
72+
if($i > 0){
73+
$filter_string .= ', ';
74+
}
75+
$filter_string .= '.clerk_'.strval($i);
76+
}
77+
$spanAttributes['data-exclude-from'] = $filter_string;
78+
}
79+
}
5680
}
5781
}
5882

@@ -66,18 +90,48 @@ public function getSpanAttributes()
6690

6791
if ($categoryId) {
6892
$spanAttributes['data-category'] = $categoryId;
93+
if($filter_category){
94+
$unique_class = "clerk_" . (string)$category_contents;
95+
$spanAttributes['class'] = 'clerk ' . $unique_class;
96+
if($category_contents > 0){
97+
$filter_string = '';
98+
for($i = 0; $i < $category_contents; $i++){
99+
if($i > 0){
100+
$filter_string .= ', ';
101+
}
102+
$filter_string .= '.clerk_'.strval($i);
103+
}
104+
$spanAttributes['data-exclude-from'] = $filter_string;
105+
}
106+
}
69107
}
70108
}
71109

72110
if ($this->getBlockLocation() === 'cart') {
73111
$spanAttributes['data-template'] = '@' . $this->getCartContent();
74112
$spanAttributes['data-products'] = $this->getCartProducts();
113+
if($filter_cart){
114+
$unique_class = "clerk_" . (string)$cart_contents;
115+
$spanAttributes['class'] = 'clerk ' . $unique_class;
116+
if($cart_contents > 0){
117+
$filter_string = '';
118+
for($i = 0; $i < $cart_contents; $i++){
119+
if($i > 0){
120+
$filter_string .= ', ';
121+
}
122+
$filter_string .= '.clerk_'.strval($i);
123+
}
124+
$spanAttributes['data-exclude-from'] = $filter_string;
125+
}
126+
}
75127
}
76128

77129
foreach ($spanAttributes as $attribute => $value) {
78130
$output .= ' ' . $attribute . '=\'' . $value . '\'';
79131
}
80-
132+
$product_contents++;
133+
$cart_contents++;
134+
$category_contents++;
81135
return trim($output);
82136
}
83137

@@ -109,8 +163,10 @@ public function getCartProducts()
109163
}
110164
}
111165

112-
$json_string = json_encode($cart_product_ids);
113-
166+
$ids = Mage::getSingleton('checkout/cart')->getProductIds();
167+
168+
$json_string = json_encode(array_values($cart_product_ids));
169+
114170
return $json_string;
115171
}
116172
}

0 commit comments

Comments
 (0)