• Resolved hwsiew

    (@hwsiew)


    Hi, is it possible to create a coupon only for a list of vendors but not others in WC marketplace? For example, the coupon code can be applied only to selected vendors’ products.

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Sumit Singh

    (@sumitsingh89612)

    Hi, Coupon created by vendor is applicable on only vendor’s product but the coupon created by admin is applicable on every product.
    So, if you want to restrict admin coupon for selected vendor’s product then add the following code in fucntions.php of you current theme :

    add_filter( 'woocommerce_coupon_is_valid_for_product', 'woocommerce_coupon_restrict_selected_vendors' , 99, 4);
    function woocommerce_coupon_restrict_selected_vendors($valid, $product, $coupon, $values) {
    	$current_product = get_post($product->get_id());
    	$valid = (!in_array($current_product->post_author, array(2, 3))) ? false : $valid; // 2, 3 are vendors id
        return $valid;
    }
    • This reply was modified 4 years, 8 months ago by Sumit Singh.
    Thread Starter hwsiew

    (@hwsiew)

    Thanks!

    Hi,

    We are facing currently the same issue that it is not possible to set coupon validation to only ONE vendor with ALL his current and future created products.

    Using field product validation in coupon is not really an option for us, because if our customer buy coupons today and vendor creates new products next week, then coupons won`t apply onto these new products. Therefore we permanently have to change the unredeemed coupons to add new products in coupon validation.

    Therefore in our opinion there must be the possibility that coupon is valid for single vendor with all his products (current and in future). Unfortunately your snippet does not work in our case, could you please check if there is any possibility?

    Do you have any ideas how to proceed?

    Thank you and regards
    Christian

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to create coupon valid only for a list of vendors?’ is closed to new replies.