I am selling services using Woocommerce and have enabled shipping address on checkout using snippet, which works fine.
In order to avoid error on checkout, I have to enable free shipping. I do not want the label Shipping: Free Shipping to be shown on Cart and Checkout. Tried using the following snippet, but it didn't work. Please help.
add_filter( 'woocommerce_cart_shipping_method_full_label', 'remove_shipping_label', 10, 2 );
function remove_shipping_label( $label, $method ) {
$new_label = preg_replace( '/^.+:/', '', $label );
return $new_label;
}
You can disable shipping in the woocommerce settings.
To force clients to fill in their adress to ship your products to, copy and paste the following code in to your functions.php file
add_filter( 'woocommerce_cart_needs_shipping_address', '__return_true', 50 );
So basically your free shipping label goes away because you disabled shipping and the costs etc but clients still need to fill in the address fields.
Hope this helps!
Related
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.
we have been using WooCommerce Stripe Gateway plugin.which provide capture method as manual or automatic.But if it set any of one on admin,the selected option will be apply for all product on checkout. we need change change capture method for one category product to manual in checkout. is it possible with following filter
wc_stripe_payment_metadata
the following filter worked .
add_filter( 'wc_stripe_generate_payment_request', 'change_cap',2,3 );
function change_cap( $post_data, $order, $prepared_source ) {
$post_data['capture_method']='manual';
}
I have a WordPress site using the PayPal Checkout plugin for woocommerce.
https://wordpress.org/plugins/woocommerce-gateway-paypal-express-checkout/
I need to change the PayPal item name and I'm using this code in the functions.php, it worked with the normal PayPal plugin but does not work with PayPal Express checkout.
add_filter( 'woocommerce_paypal_get_order_item_name', 'change_paypal_item_name', 10, 3 );
function change_paypal_item_name( $item_name, $order, $item ) {
return 'test';
}
Anyone know the function to change the item name with the PayPal Express checkout plugin?
From a quick look at the code, it seems woocommerce_paypal_express_checkout_get_details is a filter you can try implementing to modify the whole $details array
How do you change the woo-commerce checkout form for different shipping options? If they choose free shipping the checkout page displays shipping form. If they choose e-voucher the check out page displays a simpler form.
You can use the below code snippet to hide whichever fields you chose when the "e-voucher" shipping method is chosen. Simply put the following inside your functions file.
<?php
add_filter('woocommerce_checkout_fields', 'evoucher_remove_fields');
function evoucher_remove_fields($fields) {
$shipping_method ='evoucher:1'; // Change this to the value name of your shipping method
global $woocommerce;
$chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
$chosen_shipping = $chosen_methods[0];
if ($chosen_shipping == $shipping_method) {
unset($fields['billing']['billing_address_1']); // Hides billing address line 1
unset($fields['billing']['billing_address_2']); // Hides billing address line 2
}
return $fields;
}
?>
Source
There is a good plugin for such purposes. Its free version includes conditional logic, e.g. change the form with the base on shipping option.
I'm going crazy for a few hours, and I need help. Please :) I would like to disable the sale of products added by a specific seller in woocommerce. I use Dokan, a plugin that transforms woocommerce into a market place. This is what I did and that seems to me a good approach: I have created a new role "nonsellingshop" which has the same rights as the default seller role created by Dokan. This role can therefore add products and their price. I would like products added by this specific role can not be purchased, and instead of the add to cart button appears a message saying 'This seller does not offer its products for sale online'. Of course for the sellers not having this role, it is necessary that the sale is possible. It is also necessary that if I change the role of a seller "nonsellingshop" to give it the normal role, the sale becomes possible.
Does anyone have an idea of how I can do this?
Thank you a thousand times in advance for your help
So this what I've done so far (and that doesn't work) :
function get_seller_role_and_hide_cart_button_if_non_seller () { //gets the ID of the post $post_id = get_queried_object_id();
//gets the ID of the author using the ID of the post
$author_ID = get_post_field( 'post_author', $post_id );
//Gets all the data of the author, using the ID
$authorData = get_userdata( $author_ID );
//checks if the author has the role of 'subscriber'
if (in_array( 'boutiquenonvendeuse', $authorData->roles)){
add_filter( 'woocommerce_is_purchasable', '__return_false'); // DISABLING PURCHASE FUNCTIONALITY AND REMOVING ADD TO CART BUTTON FROM NORMAL PRODUCTS
remove_action('woocommerce_single_variation', 'woocommerce_single_variation', 10); // REMOVING PRICE FROM VARIATIONS
remove_action('woocommerce_single_variation', 'woocommerce_single_variation_add_to_cart_button', 20); // REMOVING ADD TO CART BUTTON FROM VARIATIONS
}
} add_action ('init', 'get_seller_role_and_hide_cart_button_if_non_seller');