وردپرس

Calculate shipping without side effects


I need to create a backend process that will generate a data feed that includes the shipping costs of our products. To do this, I need to be able to calculate the shipping price on a product without creating any side effects.

The only calculate_shipping() methods I’ve found belong to WC_Cart and WC_Order.

When I attempted to use WC_Cart for this (via WC()->cart), it ended up interfering with customers using the cart on the front end, which is obviously totally unacceptable.

From what I can tell, it looks like WC_Order->calculate_shipping() automatically saves an order to the database, which I expect would result in our database quickly getting filled up with garbage orders by this backend process.

There has to be a better way to do this. How can I simply run the shipping calculation without generating side effects?

Thank you.

این خبر را در ایران وب سازان مرجع وب و فناوری دنبال کنید

مشاهده پاسخ های این مطلب
———————————————
این مطلب از سایت انجمن وردپرس گردآوری شده است و کلیه حقوق مطلق به انجمن وردپرس می باشد در صورت مغایرت و یا بروز مشکل اطلاع دهید تا حذف گردد

منبع: انجمن وردپرس

دکمه بازگشت به بالا