独立站营销活动-Woocommerce实战

0,快速定制活动页,活动页结构:

  • Header and footer
  • Posts
  • CTA Buttons
  • Headers
  • Pop-Ups
  • Gallery

1 活动页-商品列表自定义:

1.1 基于tags制作商品列表 , Product collection / Product Sets

例如 :在相关商品加上 winterwear 的tag ,则可以直接url访问 相关 collection.

https://woocommerce .liang/index .php/product-tag/winterwear/

1.2 基于 WC_Product_Query

//制作独立Php页面模板 ,生成相关特征page: Get 10 most recent product IDs in date descending order .
$query = new WC_Product_Query( array(
'limit ' => 10,
'orderby ' => 'date ',
'order ' => 'DESC ',
'return ' => 'ids ',
) );
$products = $query->get_products();

1.3 古藤堡编辑器内置有商品列表模块

1.4 利用collection插件

https://wordpress.org/plugins/wpc-smart-product-collections/ 类似shopify collection 商品集合方案

2 活动页-商品列表界面自定义:

3,优惠券和促销活动

买一送一活动:

https://www.pimwick.com/pw-bogo/

WooCommerce: “Buy One Get One” (Without a Plugin!)

优惠券好插件:

Smart Coupons For WooCommerce Coupons

折扣价插件:

Discount Rules for WooCommerce – Create Smart WooCommerce Coupons & Discounts

代码原理:

add_action( 'woocommerce_before_cart', 'QuadLayers_apply_coupon' );
    function QuadLayers_apply_coupon() {
        $coupon_code = 'auto_coupon';
        if ( WC()->cart->has_discount( $coupon_code ) ) return;
        WC()->cart->apply_coupon( $coupon_code );
        wc_print_notices();
    }
add_action( 'woocommerce_before_cart', 'QuadLayers_apply_matched_id_products' );
function QuadLayers_apply_matched_id_products() {  
    
    // previously created coupon;
    $coupon_code = 'auto_coupon'; 
    // this is your product ID/s array  
    $product_ids = array( 664,624,619 ); 
    // Apply coupon. Default is false
    $apply=false;
 
    // added to cart products loop
    foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {                      
        if ( in_array( $cart_item['product_id'], $product_ids )):              
            // Id of product match
            $apply=true;
            break;                     
        endif;  
    }
    // apply & remove coupon
    if($apply==true):
        WC()->cart->apply_coupon( $coupon_code );
        wc_print_notices();  
    else:    
        WC()->cart->remove_coupons( sanitize_text_field( $coupon_code ));
        wc_print_notices();   
        WC()->cart->calculate_totals();    
    endif; 
}

参考: https://quadlayers.com/apply-coupons-in-woocommerce/

Powered by BetterDocs

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注