Tamamlanmış

woocommerce change role based on items qty bought in last 12 months

hello there, I need coding that changes a user role in wordpress/woocommerce based on the quantity of a product a user buys within a year period....I have the code already based on the purchase of a specific product but I need it adapted to check the total quantity of a a users purchases in a year and if the purchase quantity goes over a specific amount of items in a year then the user role must change automatically

function change_role_on_purchase( $order_id ) {

$order = new WC_Order( $order_id );

$items = $order->get_items();

foreach ( $items as $item ) {

$product_name = $item['name'];

$product_id = $item['product_id'];

$product_variation_id = $item['variation_id'];

if ( $order->user_id > 0 && $product_id == '416' ) {

update_user_meta( $order->user_id, 'paying_customer', 1 );

$user = new WP_User( $order->user_id );

// Remove role

$user->remove_role( 'subscriber' );

// Add role

$user->add_role( 'premium' );

}

}

}

add_action( 'woocommerce_order_status_processing', 'change_role_on_purchase' );

Beceriler: CSS, HTML, PHP, WooCommerce, WordPress

Daha fazlasını gör: change price based currency selected html php, drupal ubercart change role, flash game change text based score, woocommerce change product price based on quantity, wc role based price pro, woocommerce change product price programmatically, woocommerce custom price, woocommerce role based pricing, woocommerce multiple prices per product, woocommerce role based pricing pro nulled, woocommerce price display, php change content based url, zen cart pricing based items, change image based input, virtuemart change image based attribute selected, demo role based templates, role based diagram generator, change image based referer site, php change css based users referral, role based authentication using sql server 2005 aspnet

İşveren Hakkında:
( 2 değerlendirme ) Paarl, South Africa

Proje NO: #18925038

Seçilen:

vyasrohan

Hello I will make the user's role changed based on the item quantity they have purchased in the last year. Let me know more details in chat. Thanks!

1 gün içinde %selectedBids___i_sum_sub_4%%project_currencyDetails_sign_sub_5% USD
(265 Değerlendirme)
7.9

Bu iş için 5 freelancer ortalamada $33 teklif veriyor

rajeshsonisl

Hi there, Quick and easy. Do you need to just match the Product quantity from ALL ordered products within the year? OR do you want to include / exclude certain products / variations? I'll need WP admin and cPanel Daha Fazla

1 gün içinde %bids___i_sum_sub_32%%project_currencyDetails_sign_sub_33% USD
(992 Değerlendirme)
8.7
uhjk

Hello, I think I understand it. We will retrieve orders for last 1 year and count products in order. If it's more than xx, user role will be changed.

1 gün içinde %bids___i_sum_sub_32%%project_currencyDetails_sign_sub_33% USD
(877 Değerlendirme)
8.2
michealperfect

Sir, I can give this work with 100% satisfaction within a time limit, and also I have great hands-on HTML, CSS, JS, jQuery, PHP, Laravel, MySQL. Very familiar with WordPress, Magneto, woo-commerce, Bootstrap, Plugi Daha Fazla

$30 USD in 2 gün içinde
(172 Değerlendirme)
6.8
whiteeagle0001

Hello,how do you do? I am a full stack developer for WooCommerce and Wordpress. I have read your description in more detail and have much interest in your project. I have many experiences what I have ever done before s Daha Fazla

1 gün içinde %bids___i_sum_sub_32%%project_currencyDetails_sign_sub_33% USD
(0 Değerlendirme)
0.0