Skip to content

Commit

Permalink
Merge pull request #33 from Casper-O/master
Browse files Browse the repository at this point in the history
Option to disable fixed shipping
  • Loading branch information
Casper-O authored Jul 9, 2017
2 parents be03858 + c89ea29 commit 42b1f95
Showing 1 changed file with 32 additions and 7 deletions.
39 changes: 32 additions & 7 deletions gshoppingflux/gshoppingflux.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct()
{
$this->name = 'gshoppingflux';
$this->tab = 'smart_shopping';
$this->version = '1.6.5';
$this->version = '1.6.6';
$this->author = 'Dim00z';

$this->bootstrap = true;
Expand Down Expand Up @@ -73,6 +73,7 @@ public function install($delete_params = true)
if ($delete_params) {
if (!Configuration::updateValue('GS_PRODUCT_TYPE', '', true, (int) $shop_group_id, (int) $shop_id)
|| !Configuration::updateValue('GS_DESCRIPTION', 'short', false, (int) $shop_group_id, (int) $shop_id)
|| !Configuration::updateValue('GS_SHIPPING_PRICE_FIXED', '1', false, (int) $shop_group_id, (int) $shop_id)
|| !Configuration::updateValue('GS_SHIPPING_PRICE', '0.00', false, (int) $shop_group_id, (int) $shop_id)
|| !Configuration::updateValue('GS_SHIPPING_COUNTRY', 'UK', false, (int) $shop_group_id, (int) $shop_id)
|| !Configuration::updateValue('GS_IMG_TYPE', 'large_default', false, (int) $shop_group_id, (int) $shop_id)
Expand Down Expand Up @@ -203,7 +204,7 @@ public function uninstall($delete_params = true)
}

if ($delete_params) {
if (!$this->uninstallDB() || !Configuration::deleteByName('GS_PRODUCT_TYPE') || !Configuration::deleteByName('GS_DESCRIPTION') || !Configuration::deleteByName('GS_SHIPPING_PRICE') || !Configuration::deleteByName('GS_SHIPPING_COUNTRY') || !Configuration::deleteByName('GS_IMG_TYPE') || !Configuration::deleteByName('GS_MPN_TYPE') || !Configuration::deleteByName('GS_GENDER') || !Configuration::deleteByName('GS_AGE_GROUP') || !Configuration::deleteByName('GS_ATTRIBUTES') || !Configuration::deleteByName('GS_COLOR') || !Configuration::deleteByName('GS_MATERIAL') || !Configuration::deleteByName('GS_PATTERN') || !Configuration::deleteByName('GS_SIZE') || !Configuration::deleteByName('GS_EXPORT_MIN_PRICE') || !Configuration::deleteByName('GS_NO_GTIN') || !Configuration::deleteByName('GS_NO_BRAND') || !Configuration::deleteByName('GS_ID_EXISTS_TAG') || !Configuration::deleteByName('GS_EXPORT_NAP') || !Configuration::deleteByName('GS_QUANTITY') || !Configuration::deleteByName('GS_FEATURED_PRODUCTS') || !Configuration::deleteByName('GS_GEN_FILE_IN_ROOT')) {
if (!$this->uninstallDB() || !Configuration::deleteByName('GS_PRODUCT_TYPE') || !Configuration::deleteByName('GS_DESCRIPTION') || !Configuration::deleteByName('GS_SHIPPING_PRICE_FIXED') || !Configuration::deleteByName('GS_SHIPPING_PRICE') || !Configuration::deleteByName('GS_SHIPPING_COUNTRY') || !Configuration::deleteByName('GS_IMG_TYPE') || !Configuration::deleteByName('GS_MPN_TYPE') || !Configuration::deleteByName('GS_GENDER') || !Configuration::deleteByName('GS_AGE_GROUP') || !Configuration::deleteByName('GS_ATTRIBUTES') || !Configuration::deleteByName('GS_COLOR') || !Configuration::deleteByName('GS_MATERIAL') || !Configuration::deleteByName('GS_PATTERN') || !Configuration::deleteByName('GS_SIZE') || !Configuration::deleteByName('GS_EXPORT_MIN_PRICE') || !Configuration::deleteByName('GS_NO_GTIN') || !Configuration::deleteByName('GS_NO_BRAND') || !Configuration::deleteByName('GS_ID_EXISTS_TAG') || !Configuration::deleteByName('GS_EXPORT_NAP') || !Configuration::deleteByName('GS_QUANTITY') || !Configuration::deleteByName('GS_FEATURED_PRODUCTS') || !Configuration::deleteByName('GS_GEN_FILE_IN_ROOT')) {
return false;
}
}
Expand Down Expand Up @@ -310,6 +311,7 @@ public function getContent()

$updated &= Configuration::updateValue('GS_PRODUCT_TYPE', $product_type, false, (int) $shop_group_id, (int) $shop_id);
$updated &= Configuration::updateValue('GS_DESCRIPTION', Tools::getValue('description'), false, (int) $shop_group_id, (int) $shop_id);
$updated &= Configuration::updateValue('GS_SHIPPING_PRICE_FIXED', (bool) Tools::getValue('shipping_price_fixed'), false, (int) $shop_group_id, (int) $shop_id);
$updated &= Configuration::updateValue('GS_SHIPPING_PRICE', (float) Tools::getValue('shipping_price'), false, (int) $shop_group_id, (int) $shop_id);
$updated &= Configuration::updateValue('GS_SHIPPING_COUNTRY', Tools::getValue('shipping_country'), false, (int) $shop_group_id, (int) $shop_id);
$updated &= Configuration::updateValue('GS_IMG_TYPE', Tools::getValue('img_type'), false, (int) $shop_group_id, (int) $shop_id);
Expand Down Expand Up @@ -583,6 +585,24 @@ public function renderForm()
'name' => 'name',
),
),
array(
'type' => 'switch',
'label' => $this->l('Use fixed shipping for all products?'),
'name' => 'shipping_price_fixed',
'is_bool' => true,
'values' => array(
array(
'id' => 'active_on',
'value' => 1,
'label' => $this->l('Enabled'),
),
array(
'id' => 'active_off',
'value' => 0,
'label' => $this->l('Disabled'),
),
),
),
array(
'type' => 'text',
'label' => $this->l('Shipping price'),
Expand Down Expand Up @@ -886,6 +906,7 @@ public function getConfigFieldsValues($shop_id)
$shop_group_id = Shop::getGroupFromShop($shop_id);
$product_type = array();
$description = 'short';
$shipping_price_fixed = true;
$shipping_price = 0;
$shipping_country = 'UK';
$img_type = 'large_default';
Expand All @@ -912,6 +933,7 @@ public function getConfigFieldsValues($shop_id)
}

$description = Configuration::get('GS_DESCRIPTION', 0, $shop_group_id, $shop_id);
$shipping_price_fixed &= (bool) Configuration::get('GS_SHIPPING_PRICE_FIXED', 0, $shop_group_id, $shop_id);
$shipping_price = (float) Configuration::get('GS_SHIPPING_PRICE', 0, $shop_group_id, $shop_id);
$shipping_country = Configuration::get('GS_SHIPPING_COUNTRY', 0, $shop_group_id, $shop_id);
$img_type = Configuration::get('GS_IMG_TYPE', 0, $shop_group_id, $shop_id);
Expand All @@ -936,6 +958,7 @@ public function getConfigFieldsValues($shop_id)
return array(
'product_type[]' => $product_type,
'description' => $description,
'shipping_price_fixed' => (int) $shipping_price_fixed,
'shipping_price' => (float) $shipping_price,
'shipping_country' => $shipping_country,
'img_type' => $img_type,
Expand Down Expand Up @@ -2462,11 +2485,13 @@ private function getItemXML($product, $lang, $id_curr, $id_shop, $combination =
}

// Shipping
$xml_googleshopping .= '<g:shipping>'."\n";
$xml_googleshopping .= "\t".'<g:country>'.$this->module_conf['shipping_country'].'</g:country>'."\n";
$xml_googleshopping .= "\t".'<g:service>Standard</g:service>'."\n";
$xml_googleshopping .= "\t".'<g:price>'.number_format($this->module_conf['shipping_price'], 2, '.', ' ').' '.$currency->iso_code.'</g:price>'."\n";
$xml_googleshopping .= '</g:shipping>'."\n";
if ($this->module_conf[shipping_price_fixed]) {
$xml_googleshopping .= '<g:shipping>'."\n";
$xml_googleshopping .= "\t".'<g:country>'.$this->module_conf['shipping_country'].'</g:country>'."\n";
$xml_googleshopping .= "\t".'<g:service>Standard</g:service>'."\n";
$xml_googleshopping .= "\t".'<g:price>'.number_format($this->module_conf['shipping_price'], 2, '.', ' ').' '.$currency->iso_code.'</g:price>'."\n";
$xml_googleshopping .= '</g:shipping>'."\n";
}

// Shipping weight
if ($product['weight'] != '0') {
Expand Down

0 comments on commit 42b1f95

Please sign in to comment.