独立站购物车-WOOCOMMERCE实战

Table of Contents

购物车Cart功能: #

参考:https://quadlayers.com/woocommerce-mini-cart-plugins/

https://quadlayers.com/woocommerce-ajax-add-to-cart/ 购物车原理

https://quadlayers.com/update-product-price-programmatically-in-woocommerce/ 更新价格

不用刷新mini购物车:

https://quadlayers.com/apply-coupons-in-woocommerce/ 使用优惠券

https://quadlayers.com/add-fees-to-woocommerce-checkout/ fee费用

https://www.businessbloomer.com/woocommerce-custom-add-cart-urls-ultimate-guide/ Add to cart

https://kinsta.com/blog/woocommerce-checkout/ checkout介绍:

https://quadlayers.com/create-woocommerce-mini-cart/ mini-cart介绍

https://quadlayers.com/woocommerce-ajax-add-to-cart/ 代码操作

https://quadlayers.com/woocommerce-add-to-cart-function-programmatically/ 代码操作

github.com

自定义高级 mini cart :

https://wordpress.org/plugins/side-cart-woocommerce/

https://cn.wordpress.org/plugins/mini-cart-for-woocommerce/ 推荐

https://github.com/franmastromarino/woo-ajax-add-to-cart 推荐

How to Create a WooCommerce Mini Cart: 3 Methods

TODO

代码例子:

add_action( 'template_redirect', 'quadlayers_add_to_cart_function' );
function quadlayers_add_to_cart_function () {
    $product_id = 1326;
    if ( WC()->cart->get_cart_contents_count() == 0 ) {
        WC()->cart->add_to_cart( $product_id );
    }
}
add_action( 'template_redirect', 'quadlayers_add_to_cart_programmatically' );
function quadlayers_add_to_cart_programmatically() {
   $product_id = 1326;
   $product_cart_id = WC()->cart->generate_cart_id( $product_id );
   if(!WC()->cart->find_product_in_cart( $product_cart_id )) {      
       WC()->cart->add_to_cart( $product_id);
   }
}

Powered by BetterDocs