Answer the question
In order to leave comments, you need to log in
Wordpress needs advice. Which plugin to choose for certain jobs?
Hello. I have a website, I want to make a discount on the first product in the amount of 20%. The problem is that I don't know how to do it. I strongly doubt that it is possible to do this without registration, because we need to somehow identify the user, right?
If I'm right, what is the best plugin for this? How do I get a discount on my first order? Naturally, a person should also write on the payment page that you will have a discount.
I ask you not to write something like "Create a promo code and don't fool yourself", this is not suitable for me, I need the site to give a discount if the first order.
For example, I saw this site https://inbenefit.com/woocommerce-%D0%BB%D0%B8%D1%...
I downloaded the second plugin "Ultimate Membership (WooCommerce)" from here, will it work with it? If not, then which plugin to choose.
Answer the question
In order to leave comments, you need to log in
Found the answer.
I made a small function that returns the number of purchases already made by a person on the site. Works without registration. To be honest, I don’t quite understand when he saves how many orders someone has, the main thing is what he saves.
function check_count() {
$id = get_current_user_id();
$count = wc_get_customer_order_count($id);
return $count;
}
add_action( 'woocommerce_cart_calculate_fees','woocommerce_custom_surcharge');
function woocommerce_custom_surcharge() {
global $woocommerce;
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return;
if(check_count() == 0)
{
$summ = $woocommerce->cart->subtotal;
$summ = ceil($summ / 100 * 20);
$woocommerce->cart->add_fee("Скидка за первый заказ: ", -$summ);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question