We have a site where all stock is owned by our client already and they are using it for certain employees to choose gifts from to send out to customers. All stock is in WooCommerce with a price of £0.00 so all orders bypass any payment methods, however, to get this to go into our ERP system a payment method has to be assigned to it, in this case Stripe.
Stripe is selected as the default and only payment method in the WooCommerce settings but is technically not being used. Can this be hardcoded to all orders?
CodePudding user response:
Try this one : Add a capability for the users who can have free products. in code its company_user
Then using hooks if the user have that capability set the price 0.
function set_custom_price( $price, $product ) {
$user = new WP_User( get_current_user_id() );
// if user have a specific role, then
if ( is_user_in_role($user, "company_user") ) {
// set price to 0
return 0;
}
return $price;
}
add_filter( 'woocommerce_get_price', 'set_custom_price', 10, 2 );
add_filter( 'woocommerce_get_regular_price', 'set_custom_price', 10, 2 );
add_filter( 'woocommerce_get_sale_price', 'set_custom_price', 10, 2 );
CodePudding user response:
How about make a coupon with woocommerce?
