Skip to content

Commit

Permalink
Merge pull request #4 from salesfire/bugfix/sc-7181/fixes
Browse files Browse the repository at this point in the history
fix: [sc-7181] Fix issues with PrestaShop module
  • Loading branch information
Jamstaz committed Aug 24, 2023
2 parents 771628f + a85050c commit 9a96bf8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 23 deletions.
2 changes: 1 addition & 1 deletion config.xml
Expand Up @@ -2,7 +2,7 @@
<module>
<name>salesfire</name>
<displayName><![CDATA[Salesfire]]></displayName>
<version><![CDATA[0.2.0]]></version>
<version><![CDATA[0.2.1]]></version>
<description><![CDATA[Salesfire is a service that provides a number of tools that help to increase sales using various on site methods.]]></description>
<author><![CDATA[Salesfire]]></author>
<tab><![CDATA[smart_shopping]]></tab>
Expand Down
49 changes: 29 additions & 20 deletions salesfire.php
Expand Up @@ -34,10 +34,10 @@ class Salesfire extends Module

public function __construct()
{
$this->name = 'salesfire';
$this->tab = 'smart_shopping';
$this->version = '0.2.0';
$this->author = 'Salesfire';
$this->name = 'salesfire';
$this->tab = 'smart_shopping';
$this->version = '0.2.1';
$this->author = 'Salesfire';
$this->need_instance = 0;

/**
Expand Down Expand Up @@ -223,10 +223,14 @@ public function hookHeader()
if (method_exists($this->context->controller, 'getProduct')) {
$product = $this->context->controller->getProduct();

if (! Validate::isLoadedObject($product)) {
return $display;
}

$smarty_variables['sfProduct'] = array(
'sku' => $product->product_id,
'name' => $product->name,
'price' => $product->price
'sku' => $product->id,
'name' => $product->name,
'price' => $product->price,
);

$this->smarty->assign($smarty_variables);
Expand All @@ -239,38 +243,43 @@ public function hookHeader()

public function hookOrderConfirmation($params)
{
if (!Configuration::get('SALESFIRE_ACTIVE')) {
if (! Configuration::get('SALESFIRE_ACTIVE')) {
return;
}

$order = $params['order'];

if (! Validate::isLoadedObject($order)) {
return;
}

$currency = Currency::getCurrencyInstance((int) $order->id_currency);

$sfOrder = array(
'ecommerce' => array(
'purchase' => array(
'id' => $order->id,
'revenue' => $order->total_paid_tax_excl,
'shipping' => $order->total_shipping,
'tax' => $order->total_paid_tax_incl - $order->total_paid_tax_excl,
'id' => $order->id,
'revenue' => (int) $order->total_paid_tax_excl,
'shipping' => (int) $order->total_shipping,
'tax' => (int) $order->total_paid_tax_incl - (int) $order->total_paid_tax_excl,
'currency' => $currency->iso_code,
'products' => array()
)
)
'products' => array(),
),
),
);

foreach ($order->getProducts() as $product) {
$sfOrder['ecommerce']['purchase']['products'][] = array(
'sku' => $product['product_id'],
'sku' => $product['product_id'],
'parent_sku' => $product['product_id'],
'name' => $product['product_name'],
'price' => $product['total_price'],
'currency' => $currency->iso_code
'name' => $product['product_name'],
'price' => (int) $product['total_price'],
'currency' => $currency->iso_code,
);
}

$this->smarty->assign(array(
'sfOrder' => $sfOrder
'sfOrder' => $sfOrder,
));

return $this->display(__FILE__, 'order-success.tpl');
Expand Down
4 changes: 2 additions & 2 deletions views/templates/hook/product-views.tpl
Expand Up @@ -30,9 +30,9 @@
"view": {
"sku": "{$sfProduct['sku']}",
"name": "{$sfProduct['name']}",
"price": {$sfProduct['price']}
"price": {$sfProduct['price']},
"currency": prestashop.currency.iso_code
}
}
});
</script>
</script>

0 comments on commit 9a96bf8

Please sign in to comment.