Change order in Woocommerce checkout - php

I need to change the layout of the Woocommerce checkout page. I need to move the payment option box along with the terms&conditions checkobox ABOVE the order-review table. The "Place Order" button should stay at the bottom though.
I know I need to override the template in my childtheme, but I just can't get this to work as the payment box is combined together with the order-review table. Or is this somehow possible via a function?
Thank you!

Related

How to disable the ability to change shipping method on the checkout page in WooCommerce

I would like to disable the ability to change shipping method on the Checkout page in WooCommerce. The user selects the shipping method on the Cart page and I do not want to let them change it on the Checkout page.
I'm looking for some filter that can be used there. What I found is woocommerce_cart_ready_to_calc_shipping but it completely hides it.
Note: I would not like to overwrite the template file so I am looking for an way with a filter or action

adding wp store locator to woocommerce checkout

I am adding drop ship locations to woocommerce checkout. I was able to add wp store locator plugin to the checkout page. I don't know how to make the selected store details to populate the shipping address in checkout page. I am new to editing wordpress using php. Please explain in detail
Try using the Local Pickup Plus plugin. With this plugin, the user can select a store location from the Cart / Checkout page. You can then adjust the verbiage on these pages to replace Pickup with Drop Shipping. Not the perfect solution and might not work in your situation but as a non-coder it may be worth a try.

Woocommerce -- Adding Products with Javascript/PHP

I have a custom form that users make various selections before being presented with products they can buy. I need to add some logic that if an input has been selected when the user adds a product to the cart, it will also add an additional product to the cart.
The input is 3 radio check boxes. Somehow I need to hook into the add to cart click and check the page to see if one of the radios has been selected and then add the appropriate product but I'm not sure where to start.
I know I'll need to have an action that runs something like:
WC()->cart->add_to_cart( 'product_id', 'quantity');
But I'm not sure how to hook into the initial add to cart click and how to check for the radios on the page.
Thank you for your help.
Not a lot of information to go off of here, but here is a few useful WooCommerce hooks to give you a starting point/ order of operations. When overriding any native action in WordPress or its plugins. You should use the hooks if available.
Add the radio inputs to the single product before the add to cart is added (hook):
add_action("woocommerce_before_add_to_cart_button", "your_input_render_function_here");
Add the new input data from the radio buttons to the cart item (filter):
add_filter("woocommerce_add_cart_item_data", "your_filter_function_to_capture_data_here");
Capture the data and render in cart (filter):
add_filter("woocommerce_get_item_data", "your_cart_render_function");
Finally, save the newly aquired data to the order (hook):
add_action("woocommerce_checkout_create_order_line_item", "your_function_to_add_to_order")
This is one of many directions you can take, depending on your requirements. I recommend giving it a shot, and if you still have issues return with an example of your code.

Woocommerce checkout layout customisation "Place Order" button

I have combined cart and checkout on one page and are moving things around in the layout but cannot properly move Place order button on the checkout from file payment.php to cart.php. The button shows is clickable but not able to pas the checkout as it gives an error: "We were unable to process your order, please try again."
Followed this guide below on removing and adding the button:
WooCommerce checkout layout
thanks in advance!
There are 2 things you need to understand. payment.php template is a part of form-checkout.php and it is residing inside tag. Also on the cart.php page , you can found that there is also all the data resides inside the <form> tag.
You need to place your place order button including with other page information that needed for the checkout inside the form tag with proper form name and action to make it worth on the cart page.

WooCommerce: Run filter inside action hook

I'm working on a payment gateway plugin for WooCommerce and I need to edit the checkout form. When the user has selected 'Sweden' as their country, and they selected 'Klarna' as their payment method, an extra input field should appear for the user's social security number (this is totally normal in Sweden, really).
As far as I understand, the woocommerce_checkout_update_order_review action gets triggered when something changes in the checkout form. I believe I can use the woocommerce_get_country_locale filter to add the social security number field for Swedish customers. So, inside my woocommerce_checkout_update_order_review hook, I want to trigger the woocommerce_get_country_locale filter. How is this done?
Thanks in advance.

Categories