Your cart
There are no more items in your cart
Avec la nouvelle règle fiscale imposée pour le Royaume-Uni, qui applique la TVA uniquement si le montant est supérieur à 135GBP, nous devons modifier certaines choses dans notre PrestaShop pour nous conformer à la norme.
Tout d'abord, nous devrons avoir la TVA correctement configurée.
La prochaine chose est de modifier le fichier Src / Adapter / Presenter / Cart / CartPresenter.php (parfois il se trouve dans Src / Adapter / Presenter).
Dans cette ligne, nous recherchons :
if (Configuration::get('PS_TAX_DISPLAY')) {
$taxAmount = $total_including_tax - $total_excluding_tax;
$subtotals['tax'] = array(
'type' => 'tax',
'label' => ($this->includeTaxes())
? $this->translator->trans('Included taxes', array(), 'Shop.Theme.Checkout')
: $this->translator->trans('Taxes', array(), 'Shop.Theme.Checkout'),
'amount' => $taxAmount,
'value' => $this->priceFormatter->format($taxAmount),
);
}
Et nous le remplacerons par :
if ($total_excluding_tax-$shippingCost > '135' && Context::getContext()->country->id == 17) {
if (Configuration::get('PS_TAX_DISPLAY')) {
$taxAmount = $total_including_tax - $total_excluding_tax;
$subtotals['tax'] = array(
'type' => 'tax',
'label' => ($this->includeTaxes())
? $this->translator->trans('Included taxes', array(), 'Shop.Theme.Checkout')
: $this->translator->trans('Taxes', array(), 'Shop.Theme.Checkout'),
'amount' => $taxAmount,
'value' => $this->priceFormatter->format($taxAmount),
);
}
} elseif ($total_excluding_tax-$shippingCost < '135' && Context::getContext()->country->id == 17) {
if (Configuration::get('PS_TAX_DISPLAY')) {
/* $taxAmount = $total_including_tax - $total_excluding_tax;
$subtotals['tax'] = array(
'type' => 'tax',
'label' => ($this->includeTaxes())
? $this->translator->trans('Included taxes', array(), 'Shop.Theme.Checkout')
: $this->translator->trans('Taxes', array(), 'Shop.Theme.Checkout'),
'amount' => $taxAmount,
'value' => $this->priceFormatter->format($taxAmount),
);*/
}
} else {
if (Configuration::get('PS_TAX_DISPLAY')) {
$taxAmount = $total_including_tax - $total_excluding_tax;
$subtotals['tax'] = array(
'type' => 'tax',
'label' => ($this->includeTaxes())
? $this->translator->trans('Included taxes', array(), 'Shop.Theme.Checkout')
: $this->translator->trans('Taxes', array(), 'Shop.Theme.Checkout'),
'amount' => $taxAmount,
'value' => $this->priceFormatter->format($taxAmount),
);
}
}
Dans ce cas nous vous disons que si le montant moins les frais de port est supérieur à 135 $ total_excluded_tax- $ shippingCost> '135' et le pays est UK Context :: getContext () -> country-> id == 17 (vérifiez l'id de votre pays) Appliquez notre règle tarifaire, sinon aucun tarif ne s'appliquera.
Ensuite, nous cherchons cette ligne:
$totals = array(
'total' => array(
'type' => 'total',
'label' => $this->translator->trans('Total', array(), 'Shop.Theme.Checkout'),
'amount' => $this->includeTaxes() ? $total_including_tax : $total_excluding_tax,
'value' => $this->priceFormatter->format(
$this->includeTaxes() ? $total_including_tax : $total_excluding_tax
),
),
'total_including_tax' => array(
'type' => 'total',
'label' => $this->translator->trans('Total (tax incl.)', array(), 'Shop.Theme.Checkout'),
'amount' => $total_including_tax,
'value' => $this->priceFormatter->format($total_including_tax),
),
'total_excluding_tax' => array(
'type' => 'total',
'label' => $this->translator->trans('Total (tax excl.)', array(), 'Shop.Theme.Checkout'),
'amount' => $total_excluding_tax,
'value' => $this->priceFormatter->format($total_excluding_tax),
),
);
Et nous le remplaçons par :
if ($total_excluding_tax-$shippingCost > '135' && Context::getContext()->country->id == 17) {
$totals = array(
'total' => array(
'type' => 'total',
'label' => $this->translator->trans('Total', array(), 'Shop.Theme.Checkout'),
'amount' => $this->includeTaxes() ? $total_including_tax : $total_including_tax,
'value' => $this->priceFormatter->format(
$this->includeTaxes() ? $total_including_tax : $total_including_tax
),
),
'total_including_tax' => array(
'type' => 'total',
'label' => $this->translator->trans('Total (tax incl.)', array(), 'Shop.Theme.Checkout'),
'amount' => $total_including_tax,
'value' => $this->priceFormatter->format($total_including_tax),
),
'total_excluding_tax' => array(
'type' => 'total',
'label' => $this->translator->trans('Total (tax incl.)', array(), 'Shop.Theme.Checkout'),
'amount' => $total_including_tax,
'value' => $this->priceFormatter->format($total_including_tax),
),
);
} elseif ($total_excluding_tax-$shippingCost < '135' && Context::getContext()->country->id == 17) {
$totals = array(
'total' => array(
'type' => 'total',
'label' => $this->translator->trans('Total', array(), 'Shop.Theme.Checkout'),
'amount' => $this->includeTaxes() ? $total_excluding_tax : $total_excluding_tax,
'value' => $this->priceFormatter->format(
$this->includeTaxes() ? $total_excluding_tax : $total_excluding_tax
),
),
'total_including_tax' => array(
'type' => 'total',
'label' => $this->translator->trans('Total', array(), 'Shop.Theme.Checkout'),
'amount' => $total_excluding_tax,
'value' => $this->priceFormatter->format($total_excluding_tax),
),
'total_excluding_tax' => array(
'type' => 'total',
'label' => $this->translator->trans('Total', array(), 'Shop.Theme.Checkout'),
'amount' => $total_excluding_tax,
'value' => $this->priceFormatter->format($total_excluding_tax),
),
);
} else {
$totals = array(
'total' => array(
'type' => 'total',
'label' => $this->translator->trans('Total', array(), 'Shop.Theme.Checkout'),
'amount' => $this->includeTaxes() ? $total_including_tax : $total_excluding_tax,
'value' => $this->priceFormatter->format(
$this->includeTaxes() ? $total_including_tax : $total_excluding_tax
),
),
'total_including_tax' => array(
'type' => 'total',
'label' => $this->translator->trans('Total (tax incl.)', array(), 'Shop.Theme.Checkout'),
'amount' => $total_including_tax,
'value' => $this->priceFormatter->format($total_including_tax),
),
'total_excluding_tax' => array(
'type' => 'total',
'label' => $this->translator->trans('Total (tax excl.)', array(), 'Shop.Theme.Checkout'),
'amount' => $total_excluding_tax,
'value' => $this->priceFormatter->format($total_excluding_tax),
),
);
}
la dernière section à remplacer sera.
$labels = array(
'tax_short' => ($this->includeTaxes())
? $this->translator->trans('(tax incl.)', array(), 'Shop.Theme.Global')
: $this->translator->trans('(tax excl.)', array(), 'Shop.Theme.Global'),
'tax_long' => ($this->includeTaxes())
? $this->translator->trans('(tax included)', array(), 'Shop.Theme.Global')
: $this->translator->trans('(tax excluded)', array(), 'Shop.Theme.Global'),
);
if ($total_excluding_tax-$shippingCost > '135' && Context::getContext()->country->id == 17) {
$labels = array(
'tax_short' => ($this->includeTaxes())
? $this->translator->trans('(tax incl.)', array(), 'Shop.Theme.Global')
: '',
'tax_long' => ($this->includeTaxes())
? $this->translator->trans('(tax included)', array(), 'Shop.Theme.Global')
: $this->translator->trans('(tax excluded)', array(), 'Shop.Theme.Global'),
);
} elseif ($total_excluding_tax-$shippingCost < '135' && Context::getContext()->country->id == 17){
$labels = array(
'tax_short' => ($this->includeTaxes())
? $this->translator->trans('', array(), 'Shop.Theme.Global')
: '',
'tax_long' => ($this->includeTaxes())
? $this->translator->trans('(tax included)', array(), 'Shop.Theme.Global')
: $this->translator->trans('(tax excluded)', array(), 'Shop.Theme.Global'),
);
} else {
$labels = array(
'tax_short' => ($this->includeTaxes())
? $this->translator->trans('(tax incl.)', array(), 'Shop.Theme.Global')
: $this->translator->trans('(tax excl.)', array(), 'Shop.Theme.Global'),
'tax_long' => ($this->includeTaxes())
? $this->translator->trans('(tax included)', array(), 'Shop.Theme.Global')
: $this->translator->trans('(tax excluded)', array(), 'Shop.Theme.Global'),
);
}
Et ce serait suffisant. Dans les règles, vous pouvez apporter plus de corrections et ajuster le code pour prendre 135 à la bonne conversion s'il s'agit d'une autre devise.