I am providing renting service online in my woocommerce website i want to charge only for refundable amount , but wants to also show the product amount, but while customer goes to view cart. there are products total shown in subtotal I want the final total amount in which the product total amount is excluded only refundable amount is included
General Cart:- $total=$subtotal+$refundable
I need :- $total=$refundable
How can i do that
Try adding your refund as a custom fee. Please refer this example
function woo_add_cart_fee() {
global $woocommerce;
$woocommerce->cart->add_fee( __('Refundable deposit', 'woocommerce'), -3750.00 );
// since its going to be refund we should add fee in negative value.
// You can add the refund as fee in this hook
}
add_action( 'woocommerce_cart_calculate_fees', 'woo_add_cart_fee' );
Related
This question already has answers here:
Custom Coupon type woocommerce wordpress
(2 answers)
Closed 1 year ago.
If I choose Fixed product price and enter a Coupon amount each product should have its price set to that price.
Example : suppose we have a product that costs $100 each. Then I add the OFFER-20 coupon and use the Fixed product price discount type. Then I change the coupon amount to $20. If an user adds 3 products to the shopping cart, each product will cost $100 and the total will be $300. When the user applies the OFFER-20 coupon, each product should change to $20 and the total amount should be $60
You can use woocommerce_coupon_discount_types action hook for new discount type. check the below code. code will go in your active theme functions.php file.
function custom_discount_type( $discount_types ) {
$discount_types['fixed_product_price'] = __( 'Fixed product price', 'woocommerce' );
return $discount_types;
}
add_filter( 'woocommerce_coupon_discount_types', 'custom_discount_type', 10, 1 );
Tested and works.
I currently need to sell a service with a subservice as option :
I have hadded a product panel & 2 meta for my option and its price.
If the user checks a checkbox in the product page, then the option is added to the cart page, the checkout page, thank you page, email and so on...
My problem is that i actually can update the initial product price in the product row, in cart & checkout tables but i need to :
1 : insert the additionnal service (the option) as a separate row in the checkout review order table and in the cart total table;
2 : dislay initial product price in the product row and udpdate only the total adding the option price in those 2 tables.
I'm really stuck here, any help would be great. Thank's
OK,
For the solution is quiet simple :
1 : add a product dropdow in admin tab to let user choose a linked product as a product option and register its ID a product meta;
2 : use woocommerce_add_to_cart_validation to intercept the option checkbox value from the product page and add the product option to cart from the initial product meta :
add_action( 'woocommerce_add_to_cart_validation', 'my_cart_validation' );
function my_cart_validation(){
if( isset( $_POST['my-service-option'] ) ){
WC()->cart->add_to_cart( get_post_meta( $_POST['add-to-cart'], 'service-option', true ) );
}
}
3 : If the optional service is not supposed to be displayed in the shop loop, just remove it from the WC Query :
add_action( 'woocommerce_product_query', 'remove_optional_services' );
function remove_optional_services( $q ){
$not_in = $q->get('post__not_in' );
array_push( $not_in, 75 ); // you can grab your product ids from an option or whatever fits your needs
$q->set('post__not_in', $not_in);
}
The good thing is you keep a simple control on taxes and prices with this method.
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');
Using Woocommerce plugin.
I get this code to add Tax based in the buyer rol.
It works fine but the Tax is only applied to product price. I also need to apply the same Tax to the Shipping cost.
I guess I need to use another filter parameter but I don't know which one.
Here is the real code:
function wc_re_eq( $tax_class, $product ) {
if ( is_user_logged_in() && current_user_can( 'client_re' ) ) {
$tax_class = 'R.E';
}
return $tax_class;
}
add_filter( 'woocommerce_product_tax_class', 'wc_re_eq', 1, 2 );
You should be applying that in your tax rate chart. There is a checkbox for shipping, where you apply tax to shipping.
WooCommerce documentation: https://docs.woocommerce.com/document/setting-up-taxes-in-woocommerce/#tax-rate-examples
#Jpash do you solve it?
Through the label "R.E.", I get the feeling that your problem is related to "recargo de equivalencia" of Spain.
I have the same problem. For certain users I must apply another type of tax only for the shipping costs.
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!