基于运输目的地的 Magento 税率
Magento Tax Rate Based on Shipping Destination
如何在结账时更改送货目的地时更改税率?
我没有在后端找到相关设置(如果我错了请更正)所以我想我必须用自己的模块来解决这个问题。
我从哪里开始那个项目?
示例目标:
- 德国商店(19% 增值税)
- 瑞士客户(从德国出口到非欧盟国家:0% 增值税)
- 运送到德国-瑞士边境以节省运费 => 我必须计算 19% 的增值税,因为产品(还)没有离开该国,即使客户在瑞士,仍然从那里获得 0% 的增值税Magento)
有什么想法,类 和方法必须为此改变吗?
提前致谢。
我完成了我的任务。
我覆盖了 Mage_Tax_Model_Calculation 方法 getRateRequest。
在这里,我可以在使用 $basedOn 分配 $address.
的 switch 语句之前添加自己的逻辑
//override basedOn
$basedOn = 'billing';
if ($shippingAddress != null && $billingAddress != null) {
if ($shippingAddress->getData('country_id') != $billingAddress->getData('country_id') && $shippingAddress->getData('country_id') == 'DE') {
$basedOn = 'shipping';
}
}
// needed to still work if one of both addresses is null
if ($shippingAddress == null || $billingAddress == null) {
$basedOn = 'default';
}
else {
$ship = $shippingAddress->getData('country_id');
$bill = $billingAddress->getData('country_id');
if(empty($ship) || empty($bill)) {
$basedOn = 'default';
}
}
如何在结账时更改送货目的地时更改税率?
我没有在后端找到相关设置(如果我错了请更正)所以我想我必须用自己的模块来解决这个问题。
我从哪里开始那个项目?
示例目标:
- 德国商店(19% 增值税)
- 瑞士客户(从德国出口到非欧盟国家:0% 增值税)
- 运送到德国-瑞士边境以节省运费 => 我必须计算 19% 的增值税,因为产品(还)没有离开该国,即使客户在瑞士,仍然从那里获得 0% 的增值税Magento)
有什么想法,类 和方法必须为此改变吗?
提前致谢。
我完成了我的任务。
我覆盖了 Mage_Tax_Model_Calculation 方法 getRateRequest。 在这里,我可以在使用 $basedOn 分配 $address.
的 switch 语句之前添加自己的逻辑 //override basedOn
$basedOn = 'billing';
if ($shippingAddress != null && $billingAddress != null) {
if ($shippingAddress->getData('country_id') != $billingAddress->getData('country_id') && $shippingAddress->getData('country_id') == 'DE') {
$basedOn = 'shipping';
}
}
// needed to still work if one of both addresses is null
if ($shippingAddress == null || $billingAddress == null) {
$basedOn = 'default';
}
else {
$ship = $shippingAddress->getData('country_id');
$bill = $billingAddress->getData('country_id');
if(empty($ship) || empty($bill)) {
$basedOn = 'default';
}
}