As of - RWC-251Getting issue details... STATUS , a feature that (barely) handles zero amount orders are added to support Resurs Checkout, as Resurs Checkout is normally not supporting 0 amounts. One thing for example, if an order is 0, there may be payment methods that will show up on this amount, but the iframe may not properly work. So this is how we handle such cases, even if the frontend handlers may be quite buggy - and we actually only playing with form fields that is quite conditional. This also means that if you have a theme that not following any proper standard, the below solution is guaranteed to fail.
- Front end hooks into the js trigger updated_checkout.
- When updated_checkout is triggered the plugin has pushed a variable through the filter woocommerce_update_order_review_fragments.
- We should probably add an element rbwc_cart_total somewhere on the page, since we wrongfully using this fake element to store the cart total temporarily.
- rbwc_cart_total is keeping track on when cart total becomes 0, and proceeding through resursPlaceOrderControl() in the front end.
- WooCommerce is updating the "place order"-button automatically when the cart is processing the fragments, so if the cart total is 0, that button returns to the store again, together with the iframe.
- In resursPlaceOrderControl, when the order total is validated as 0, the customer billing/shipping fields will show up again, and the iframe will be temporarily be hidden.
- If the order total is revalidated again as above 0, the billing/shipping fields will hide again, and the iframe will be restored.
- When a cart is added with a discount which generates above scenario and customer data is not yet filled in, customer has to do this manually.