彻底理解 Magento tax 是如何计算的不是一件容易的事。我做了无数次组合测试,算是了解 Magento tax 是如何计算的,但我未及去读代码,不敢说彻底摸透它的来龙去脉,写下这段文字权作日后参考。 首先,零税率不用设置,因为如果什么设置都没有的话税率就是零,所以大多数时候只要针对非零税率进行设置。稍后会讲到什么时候需要进行零税率设置。 其次,要分清以下名词: tax rate 税率 tax zone 税区域 tax rule 税规则 customer tax class 顾客税种 product tax class 产品税种 shipping tax class 运费税种 customer group 顾客属组 customer address 顾客地址 它们的关系是: 税计算的起点是税规则。换言之,如果后台设置了若干税率、税区域、顾客税种、产品税种、运费税种,却没有设置税规则,那么没有任何税生效。 只有税规则可以设置优先级,税区域无法设置优先级(除非去改数据库,id 越小的税区域优先)。 税规则是产品税种(或运费税种)、顾客税种、税区域在三维空间决定的。 后台界面设置税率和税区域在一个表单里,似乎税率由税区域直接决定,但并不一定能生效,原因见第3点。 税区域与顾客税种无关。这点曾是我困惑的地方,因为地址是顾客的一个属性,所以我很自然地认为顾客地址就对应税区域。如果尝试着放弃“顾客地址就对应税区域”思维,一切都容易理解了。 税规则的三维空间较难描述,可以这么来简化:先拿产品税种(或运费税种)和顾客税种交叉排列组合出多个税规则,再拿税区域去套,套中的税规则就生效,套不中就不生效。 顾客属组和顾客税种是多对一的关系。 在前台 checkout 时,Magento 会根据顾客地址启用一条或多条税规则,但后台 create order 时,Magento 的税规则却无视顾客地址。这或许是 Magento 的一个… Continue reading Understand how tax is calculated in Magento
Day: February 4, 2010
Nginx try_files syntax
今天在一台很久不用的服务器上测试 Magento search result page,URL /catalogsearch/result/?q=searchword,发现它不工作,但其他页面正常。这个症状让我联想到以前碰到的类似问题,Magento 无法获得 query_string,所以含问号的 URL 都不能处理,页面重定向到 referring URL。应该是 server rewrite 规则没有写正确,我想。打开 nginx 的配置文件一看,果然,当中一条规则用的是很久以前的写法,后来在不同的服务器上几经改进,production server 都已经用上了新规则。 新规则的写法: location @magento { root $php_script_root; index index.php; if ($uri ~ ^/(media|js|skin)/) { break; } if (!-e $request_filename) { rewrite .* /index.php last; } } 而老规则的写法: location @magento { root $php_script_root; index index.php; if ($uri ~… Continue reading Nginx try_files syntax
Style Magento checkout form fields without touching the core code
Although I can change css complete restyle the checkout forms, this is not what I want to discuss today. What I want to achieve are: fix City required asterisk not showing bug change Address lines from full width to half width as City The City required asterisk is hidden by a javascript wrongly. I found… Continue reading Style Magento checkout form fields without touching the core code
Magento idea: business intelligence
It is very time consuming to set Related Products, Cross Sells, Up Sells on individual product basis, and not accurate if you work them out just using your brain. It is good to see Magento has these marketing terms built in, but I hate to do the job by hand (or brain). So I am… Continue reading Magento idea: business intelligence