Using Woocommerce Checkout for Quotes Only - woocommerce

How would go about using woocommerce without pricing but keeping the cart functionality? Id like the ability to add products to cart (changing button to to say add to quote) and then when checking out instead of going to payment gateway it would instead submit all the items in the cart for a quote. Once I receive the order I would contact the customer with a quote. You can edit an order in the admin so technically I could change the 0 cost items to the quoted prices and then notify the customer that their order/quote has been updated.
Could I just make all items have 0 cost and hide the prices on the front end ?

Set a price of '0' so the 'add to cart' buttons still show, but in your templates hide the price fields, and change the 'add to cart' labels to whatever is appropriate, so 'add to quote' or 'add to shortlist' or whatever you're using the cart for.
If you still want the checkout function disable all payment options except for 'cash on delivery', and change the title of this payment option to 'No Payment Required For Quotes' or similar. No payment is then required, yet the customer can create orders without paying for them

It takes some digging to find all the right filters in WooCommerce to make this happen but once you find them, it's pretty straightforward. These are the various snippets I'm using to change "Cart" language to "Quote" and streamline the checkout process:
add_filter('woocommerce_product_single_add_to_cart_text', 'rental_single_product_add_to_cart',10,2);
add_filter('woocommerce_product_add_to_cart_text', 'rental_single_product_add_to_cart',10,2);
function rental_single_product_add_to_cart( $title,$product ) {
return 'Add to Quote';
}
add_action('woocommerce_widget_shopping_cart_before_buttons', 'rental_before_mini_cart_checkout',10);
function rental_before_mini_cart_checkout(){
//change buttons in the flyout cart
echo '
<p class="buttons" style="display: block;">
Submit for Quote
</p>
';
}
add_filter('woocommerce_billing_fields','rental_billing_fields',10,1);
function rental_billing_fields($fields){
unset($fields['billing_country']);
unset($fields['billing_address_1']);
unset($fields['billing_address_2']);
unset($fields['billing_city']);
unset($fields['billing_state']);
unset($fields['billing_postcode']);
return $fields;
}
add_filter('woocommerce_checkout_fields','rental_checkout_fields',10,1);
function rental_checkout_fields($fields){
//change comment field labels
$fields['order']['order_comments']['label'] = 'Notes';
return $fields;
}
add_filter('woocommerce_order_button_text','rental_order_button_text',10,1);
function rental_order_button_text($text){
return 'Submit to Request Confirmed Quote';
}
This plus the suggestion from /u/crdunst regarding payment methods should make switching to a Quote submission a breeze!

Related

Change items tax rate in WooCommerce order admin based on custom field

My customers have to make a choice during the checkout to select if they are vat exempted or not. i use custom fields. I tried 3 solutions, all worked well:
Change items tax rate in WooCommerce checkout based on radio buttons
Add Tax Exempt form on checkout in woocommerce
and the best for me:
`
add_action( 'woocommerce_checkout_update_order_review', 'bbloomer_taxexempt_checkout_based_on_zip' );
function bbloomer_taxexempt_checkout_based_on_zip( $post_data ) {
WC()->customer->set_is_vat_exempt( false );
parse_str( $post_data, $output );
if ( $output['fsbdd_check_exotva'] === 'OUI' ) WC()->customer->set_is_vat_exempt( true );
}
`
But I can't change this setting in the woocommerce order admin page. if the customer was wrong or I need to edit the order manually I would like the VAT to change depending on this custom field.
I can manage the custom field with a metabox in the order backend (from metabox.io plugin). But there is no effect on the VAT. i would like the cart to be recalculate (recalculate button) once I have changed and saved the custom field value.

Change Shipping Postcode field to dropdown list in BOTH Woocommerce Checkout page AND Shipping Calculator

I want to make it easier for customers to choose a correct WooCommerce Shipping Address postcode, by replacing the default Postcode "text box" field in (a) the Shipping Address section (but NOT the Billing Address also, that still needs the full list of postcodes) of the WooCommerce Checkout page, and also in (b) the Shipping Calculator on the WooCommerce Cart page ... with a dropdown list of only 3 available postcodes.
I have tried the code provided in the "1) For shipping postcode field only, you will use the following:" section of the thread called "Change postcode shipping field to a dropdown in Woocommerce" and that seemed to work on my Checkout page ... BUT it did not seem to do anything to the Shipping Postcode field in the Shipping Calculator on my WooCommerce Cart page ...
add_filter( 'woocommerce_shipping_fields' , 'customize_shipping_postcode_field' );
function customize_shipping_postcode_field( $shipping_fields ) {
$shipping_fields['shipping_postcode']['type'] = 'select';
$shipping_fields['shipping_postcode']['options'] = array(
'' => __('Select your postcode', 'woocommerce'),
'option_1' => 'Choice 1',
'option_2' => 'Choice 2',
'option_3' => 'Choice 3'
);
return $shipping_fields;
}
Please can anyone provide a version of the above code that will customize both (a) and also (b)?
Or else provide separate code to do the Shipping Calculator? (perhaps code similar to the example in the latest answer (the answer starting with ... "Put the code in your "function.php" file or plugin. No need to manipulate the woocommerce file") in this thread "Edit woocommerce shipping calculator", that I could add to the functions.php file?
The other thing is, of course, I need the postcode that is chosen from the dropdown list to be recognised by WooCommerce Shipping options and matched to my Shipping Zone (and hence trigger/display my configured list of available shipping methods)

Access WooCommerce custom post field in same action as send email

Before this gets flagged as a duplicate of Save custom post fields value before Woocommerce email send I will point out that the answer given to that question is a) not accepted and b) refers to a hook that is no longer in the documentation.
I'm helping out a friend with their WordPress WooCommerce site, and they want to be able to add a tracking number to the email that gets automatically sent out to a customer once the order status is set to "Completed". I've managed to get this all working using the Advanced Custom Fields plugin and some code in functions.php. The problem I have is the user friendliness isn't quite there when it comes to processing the order, it being a double-barrelled operation:
Fill in the tracking number custom field on the Edit Order screen and then click the Update button
Set the status to Completed and the click the Update button again
Ideally, it would be nice to fill in the tracking number text field and change the status dropdown value to Completed, and then hit update. If that is done though, the email doesn't get the custom field populated, presumably because the custom fields get saved after the email gets triggered.
Is there a hook in WooCommerce that allows, on update of the order, saving of custom fields to occur before triggering the email?
For reference, this is my current code in functions.php, where (despite changing the priority of the operation to 1) it doesn't populate the tracking number on the email:
add_action( 'woocommerce_email_before_order_table', 'add_content_specific_email', 1, 4 );
function add_content_specific_email( $order, $sent_to_admin, $plain_text, $email ) {
if ( $email->id == 'customer_completed_order' ) {
$ausPostTrackingNumber = get_post_meta( $order->get_id(),'australia_post_tracking_number',true);
if($ausPostTrackingNumber != '') {
echo '<p class="email-auspost-text">Your Australia Post tracking number is ' . $ausPostTrackingNumber . '</p>';
}
}
}

possible woocommce bug keep showing "total_sales" in metabox "custom field" add/edit product page?

As shown in the edit/add product page, this item "total_sales" always show up in the default metabox "custom field".
It's not doing any harm yet but it's annoying.
However, someone might edit the total sales number by accident and would cause problems.
I am writing a child theme from storeFront.
Is this a bug in woocommerce or did I accidentally changed something somewhere that causes this?
This is by default. If you think this is a bug then you can always open a thread on https://github.com/woocommerce/woocommerce/issues
EDIT
Custom fields or post meta entries can be hidden from the by default in Wordpress available »Custom Fields«-Metabox by prefixing them with a underscore - _ - as noted here.
If you want to hide the field you can use this piece of code that i wrote for you
function filter_is_protected_meta( $protected, $meta_key, $meta_type ) {
if ( $meta_key == 'total_sales' ) {
$protected = true;
}
return $protected;
}
add_filter( 'is_protected_meta', 'filter_is_protected_meta', 10, 3 );

How to reset all fields when adding to WooCommerce Cart

I'm developing a site with WooCommerce and have used the plugin Product Addons to add extra fields of text to the item being purchased (name, email address, phone number, etc). When someone clicks on "Add to Cart", the site currently adds the product to the cart, refreshes the page, but the previous data remains in the fields. I want to reset all the fields and make them empty after the product has been added.
I tried using this function:
( function($) {
$( document.body ).on( 'added_to_cart', function() {
$('input').val(''); }
);
} ) ( jQuery );
Any suggestions?
If the page literally refreshes itself then it is not at all standard. It was done just to update the mini cart at the top right corner of your menu and products are being added through ajax. In this case you can't empty all fields on some event because the page is being refreshed, what you have to do is write you code under document.ready function, perform $.each function on the common class or input and empty the input fields.
Try this action hook in your plugin or theme functions.php file
add_filter( 'woocommerce_checkout_get_value', 'misha_clear_checkout_fields_vals' );
function misha_clear_checkout_fields_vals($input){
return '';
}

Resources