dongquweng5152 2017-12-26 20:55
浏览 85
已采纳

无论税率如何,都保持不变的Woocommerce价格 - B2C

Note - im new, so please be kind. If anything isnt clear please tell me, so i can improve my questioning!

As a person who lives in europe and sells products to end-consumers, the following problem is very ipmortant and in my opinion heavily under-prioritised. There are a lot of conversation regarding this issue. In the following one @MikeJolley (owner of the wocommerce github repository) was also involved(github.com issues/4131) and linked to the site - How Taxes Work in WooCommerce where you can find the following filter to remain the prices constant regardless of the tax rate

add_filter( 'woocommerce_adjust_non_base_location_prices', '__return_false' )

By using the filter you can achieve the following:

Example 1: Selling from GB (with their 20% tax rate) to Germany. The price of the product is 9.99 including tax. GB based sellers do not need to charge tax for physical goods in Germany.

Price = 9.99 (the same) Tax = 0 (no tax is charged The German would pay 9.99 for the product, the same as GB people.

Example 2: Let's take the same above example, but consider a digital good where tax would apply of the rate 19%.

Price = 9.99 (the same) Tax = 9.99 / 1.19 = 8.39 (slightly less than GB) The German would again pay 9.99

The Problem:

For a few weeks i put the filter in my functions.php and solved the isse, unfortunately after the last Woocommerce update the mentioned filter triggers the following post call - wich executes in a infinite loop - again and again (see firebug network tab).

https://testsite.com/online-shop/?wc-ajax=get_refreshed_fragments

enter image description here

My request

Any idea how to solve this Problem - or any other way to remain the prices constant? Im not interested in heavy or paid Plugin solution wich slow down my site. Thank you so much

EDIT:

After some research i came across with the following:

Refresh fragments infinite loop #10940 and Fix for #10940 - wc_cart_hash It seems there is woocommerce bug wich is still not resolved entirely. I closed my other windows and the problem is gone. What a waste of time...

  • 写回答

1条回答 默认 最新

  • dsizmmwnm56437180 2017-12-26 22:39
    关注

    After some research i found the problem. It is a woocommerce core problem - look at Refresh fragments infinite loop #10940 and Fix for #10940 - wc_cart_hash

    wc_cart_hash was used as a key for localStorage for all WooCommerce sites. If you were to load your cart for two different sites in the same browser, the two WooCommerce pages would contend over this key and loop on trying to set this key in the localStorage

    This commit prepends the site's ajax URL onto the wc_cart_hash key name in localStorage, providing a unique key for each WooCommerce site. This ends contention over the keys.

    It seems the woocommerce bug is not resolved entirely...

    I closed my other windows and the problem is gone. Hope this helps others with the same problem.

    UPDATE:

    The problem also happens if you open a new Tab where you view a live preview (under Appearance - Themes) of another woocommerce theme in the backend... In my case i checked a few changes of a earlier theme.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?