Skip to content

Commit

Permalink
fix: show product once on row label (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
joerivanveen authored Nov 18, 2021
1 parent ceef740 commit 2d46541
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 22 deletions.
2 changes: 2 additions & 0 deletions src/Constant.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class Constant
public const SIGNATURE_REQUIRED_CONFIGURATION_NAME = 'MYPARCELBE_SIGNATURE_REQUIRED';
public const INSURANCE_CONFIGURATION_NAME = 'MYPARCELBE_INSURANCE';
public const CUSTOMS_FORM_CONFIGURATION_NAME = 'MYPARCELBE_CUSTOMS_FORM';
public const CUSTOMS_FORM_CONFIGURATION_OPTION_ADD = 'Add';
public const CUSTOMS_FORM_CONFIGURATION_OPTION_SKIP = 'Skip';
public const CUSTOMS_CODE_CONFIGURATION_NAME = 'MYPARCELBE_CUSTOMS_CODE';
public const DEFAULT_CUSTOMS_CODE_CONFIGURATION_NAME = 'MYPARCELBE_DEFAULT_CUSTOMS_CODE';
public const CUSTOMS_ORIGIN_CONFIGURATION_NAME = 'MYPARCELBE_CUSTOMS_ORIGIN';
Expand Down
13 changes: 4 additions & 9 deletions src/Model/OrderLabel.php
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ public static function getOrderLabels(int $order_id, array $label_ids = [])
/**
* @param int $id_order
*
* @return array|bool|\mysqli_result|\PDOStatement|resource|null
* @return array|\mysqli_result|\PDOStatement|resource
* @throws \PrestaShopDatabaseException
*/
public static function getCustomsOrderProducts(int $id_order)
Expand All @@ -419,15 +419,10 @@ public static function getCustomsOrderProducts(int $id_order)
$qb->from('order_detail', 'od');
$qb->leftJoin(Table::TABLE_PRODUCT_CONFIGURATION, 'pc', 'od.product_id = pc.id_product');
$qb->where('od.id_order = ' . $id_order);
$qb->where('pc.name = "' . Constant::CUSTOMS_FORM_CONFIGURATION_NAME . '"');
$qb->where('pc.value = "' . Constant::CUSTOMS_FORM_CONFIGURATION_OPTION_ADD . '"');

$return = Db::getInstance()->executeS($qb);
foreach ($return as $item) {
if ($item['value'] && $item['value'] == 'No') {
return false;
}
}

return $return;
return Db::getInstance()->executeS($qb) ?? [];
}

/**
Expand Down
11 changes: 2 additions & 9 deletions src/Module/Configuration/CustomsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,11 @@ protected function getFields(): array
'options' => [
'query' => [
[
'id' => 'No',
'name' => $this->module->l(
'Do not automatically generate customs form',
'customsform'
)
],
[
'id' => 'Add',
'id' => Constant::CUSTOMS_FORM_CONFIGURATION_OPTION_ADD,
'name' => $this->module->l('Add this product to customs form', 'customsform')
],
[
'id' => 'Skip',
'id' => Constant::CUSTOMS_FORM_CONFIGURATION_OPTION_SKIP,
'name' => $this->module->l('Skip this product on customs form', 'customsform')
],
],
Expand Down
5 changes: 1 addition & 4 deletions views/templates/admin/hook/products_form.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,6 @@
<div class="form-group">
<label for="custom-form">{l s='Custom Form' mod='myparcelbe'}</label>
<select class="form-control" id="custom-form" name = "{$CUSTOMS_FORM}">
<option value="No"{if $params[$CUSTOMS_FORM] == 'No'} selected{/if}>
{l s='Do not automatically generate customs form' mod='myparcelbe'}
</option>
<option value="Add"{if $params[$CUSTOMS_FORM] == 'Add'} selected{/if}>
{l s='Add this product to customs form' mod='myparcelbe'}
</option>
Expand Down Expand Up @@ -221,4 +218,4 @@
$('.btn-tab').removeClass('active');
$(this).addClass('active');
});
</script>
</script>

0 comments on commit 2d46541

Please sign in to comment.