تعزيز مبيعات المتجر الإلكتروني بتقديم هدايا مقابل الشراء بكميات كبيرة.

sales boosting
sales boosting

زيادة مبيعات متجر ووكومرس الإلكتروني (تقنية رقم واحد)

إضافة هدية تلقائيًا إلى سلة التسوق في ووكومرس

در تکنیک شماره دو به شما خواهیم گفت چطور با ترکیب تکنیک شماره دو و روش جدید کاربر را تشویق به خرید بیشتر کنید

ولكن، التقنية الأولى لزيادة المبيعات عبر الإنترنت

در بسیاری از فروشگاه‌های اینترنتی، ارائه تخفیف‌های متنوع به مشتریان یکی از راه‌های جذب و نگه‌ داشتن آنهاست. اما یکی از استراتژی‌های جذاب‌تر برای زيادة مبيعات المتاجر عبر الإنترنت يستطيع إضافة هدية تلقائية به سبد خرید مشتریان باشد. به جای ارائه کد تخفیف، شما می‌توانید تنظیمات ووکامرس را به گونه‌ای تغییر دهید که به طور خودکار یک محصول به عنوان هدیه به سبد خرید مشتری اضافه شود، به شرطی که مجموع خرید او از یک مقدار مشخص (مثلاً ۵ میلیون تومان) بیشتر شود.

خطوات إضافة هدية تلقائية إلى سلة التسوق في WooCommerce:

شما دو راه حل برای افزایش فروش فروشگاه انلاین خود با این روش دارید 1- استفاده از کدی که در انتهای مقاله قرار قرار گرفته است، که در ادامه آموزش آن را قرار داده ایم 2- استفاده از افزونه ها که با توجه به فشار به سایت و اشغال دیتابیس و همچنین هزینه ها برای خرید افزونه پیشنهاد نمیکنم بما في ذلك البرنامج المساعد الصحيح برای افزایش فروش فروشگاه آنلاین با ارائه هدیه افزونه‌  “WooCommerce Auto Add Gift” نام برد إعدادات البرنامج المساعد: بعد التثبيت انتقل إلى قسم إعدادات الإضافة وقم بضبط الشروط اللازمة لإضافة الهدية. على سبيل المثال:

    • إذا تجاوزت سلة التسوق الخاصة بالعميل 5 مليون تومان.
    • يجب اختيار الهدية من فئة معينة.
    • ألا يزيد سعر الهدية عن 500 ألف تومان.

اختيار منتجات الهدايا: حدد فئة معينة سيتم اختيار منتجات الهدايا منها بشكل عشوائي  

استخدم رمز الوظيفة التالي

برای تنظیم کد به صورت زیر عمل کنید در بخش A دسته بندی که می خواهید هدیه از آن انتخاب شود را انتخاب کنید (هم اکنون دسته بندی اکسسوری انتخاب شده) در بخش B بیشترین مبلغ محصولی که به عنوان هدیه انتخاب می شود را انتخاب کنید در بخش C حداکثر مبلغ خرید را انتخاب کنید این کد را باید در انتهای فایل فانکشن خود قرار بدید و آن را ذخیره کنید


function add_random_gift_product_to_cart() {
    if ( is_admin() ) {
        return;
    }

    // setting
    $category_slug = 'accessory'; // A
    $maximum_price = 100; // B
    $minimum_amount = 1000; // C

    
    $cart_total = WC()->cart->subtotal_ex_tax;

   
    if ( $cart_total >= $minimum_amount ) {
        $gift_already_in_cart = false;

        foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
            $product_id = $cart_item['product_id'];
            $product = wc_get_product($product_id);
            $product_categories = wp_get_post_terms($product_id, 'product_cat', array("fields" => "slugs"));

            if ( in_array( $category_slug, $product_categories ) && $product->get_price() <= $maximum_price && isset( $cart_item['is_gift'] ) && $cart_item['is_gift'] ) {
                $gift_already_in_cart = true;
                break;
            }
        }

        if ( !$gift_already_in_cart ) {
           
            $args = array(
                'post_type' => 'product',
                'posts_per_page' => -1,
                'tax_query' => array(
                    array(
                        'taxonomy' => 'product_cat',
                        'field'    => 'slug',
                        'terms'    => $category_slug,
                    ),
                ),
                'meta_query' => array(
                    array(
                        'key'     => '_price',
                        'value'   => $maximum_price,
                        'compare' => '<=',
                        'type'    => 'NUMERIC',
                    ),
                ),
            );

            $products = get_posts( $args );

            if ( ! empty( $products ) ) {
               
                $random_product = $products[array_rand($products)];
                $gift_product_id = $random_product->ID;

               
                WC()->cart->add_to_cart( $gift_product_id, 1, '', array(), array( 'is_gift' => true ) );
            }
        }
    } else {
        
        foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
            if ( isset( $cart_item['is_gift'] ) && $cart_item['is_gift'] ) {
                WC()->cart->remove_cart_item( $cart_item_key );
            }
        }
    }
}
add_action( 'template_redirect', 'add_random_gift_product_to_cart' );


// Display the text "Gift" in the shopping cart and the shopping cart widget
function display_gift_text_in_cart( $product_name, $cart_item, $cart_item_key ) {
    if ( isset( $cart_item['is_gift'] ) && $cart_item['is_gift'] ) {
        return $product_name . ' - Gift';
    }
    return $product_name;
}
add_filter( 'woocommerce_cart_item_name', 'display_gift_text_in_cart', 10, 3 );
add_filter( 'woocommerce_widget_cart_item_name', 'display_gift_text_in_cart', 10, 3 );


function hide_gift_product_price_in_cart( $price, $cart_item, $cart_item_key ) {
    if ( isset( $cart_item['is_gift'] ) && $cart_item['is_gift'] ) {
        return 'Gift';
    }
    return $price;
}
add_filter( 'woocommerce_cart_item_price', 'hide_gift_product_price_in_cart', 10, 3 );
add_filter( 'woocommerce_cart_item_subtotal', 'hide_gift_product_price_in_cart', 10, 3 );
add_filter( 'woocommerce_widget_cart_item_quantity', 'hide_gift_product_price_in_cart', 10, 3 );


function adjust_cart_total_for_gift( $cart_object ) {
    if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
        return;
    }

    foreach ( $cart_object->get_cart() as $cart_item_key => $cart_item ) {
        if ( isset( $cart_item['is_gift'] ) && $cart_item['is_gift'] ) {
            $cart_item['data']->set_price( 0 );
        }
    }
}
add_action( 'woocommerce_before_calculate_totals', 'adjust_cart_total_for_gift', 10, 1 );


function disable_quantity_input_for_gift( $product_quantity, $cart_item_key, $cart_item ) {
    if ( isset( $cart_item['is_gift'] ) && $cart_item['is_gift'] ) {
        return '1';
    }
    return $product_quantity;
}
add_filter( 'woocommerce_cart_item_quantity', 'disable_quantity_input_for_gift', 10, 3 );

اترك تعليقاً

لن يتم نشر عنوان بريدك الإلكتروني. الحقول الإلزامية مشار إليها بـ *

 
الدردشة عبر الإنترنت

نحن على استعداد للإجابة على أسئلتك