bensommer
Forum Replies Created
-
Forum: Plugins
In reply to: [WooCommerce] WooCommerce Auto Set Shipping AddressOkay so I solved this (kinda)
1. On the Cart & Checkout Page: As I thought, I didn’t know WooCommerce well enough, so I changed it so now I have a Shipping Zone USA and whithin that I have 2 Shipping Types, the Free Shipment and a Flat Rate to anywhere else
2. On the Checkout Page I set a custom Javascript that when you click the button it auto fills the address in
Inside my functions.php
add_action( 'woocommerce_before_checkout_form', 'wnd_checkout_message', 10 );function wnd_checkout_message( ) {
echo ‘<div class=”wnd-checkout-message”><h3>Sending to X? Shipping is free!</h3><button onclick=”changeShippingAddr();”>Click here to ship</button></div><br />
‘;
And then on my actual Checkout Page I have a JavaScript:<script>
function changeShippingAddr(){
document.getElementById(“shipping_first_name”).value = document.getElementById(“billing_first_name”).value;
document.getElementById(“shipping_last_name”).value = document.getElementById(“billing_last_name”).value;
document.getElementById(“shipping_company”).value = “COMPANY”;
document.getElementById(“shipping_country”).value = “COUNTRY”;
jQuery(‘body’).trigger(‘update_checkout’);
document.getElementById(“shipping_state”).value = “STATE”;
jQuery(‘body’).trigger(‘update_checkout’);
document.getElementById(“shipping_address_1”).value = “ADDR”;
document.getElementById(“shipping_city”).value = “CITY”;
document.getElementById(“shipping_postcode”).value = “ZIP”;
jQuery(‘body’).trigger(‘update_checkout’);
document.getElementById(“select2-shipping_state-container”).innerHTML= “State Name”;
}
</script>Which essentially sets the Name from Billing to Shipping and inserts a default Address so you don’t need to type it in.
Thanks to all the helped out!
Forum: Plugins
In reply to: [WooCommerce] WooCommerce Auto Set Shipping AddressSo maybe I wasn’t clear,
The website is for Apparel for a Camp, where there will be many parents coming to purchase apparel. I want to make a button that they can click on the checkout page which will autofill the Shipping Address form with the Camp Address.
So like they click “Shipping to camp?” and then it fills the form out with the Camp Address so they don’t need to fill it out themselves…
Thanks, Ben!