📌  相关文章
📜  add_to_cart 如何调用它 woocommerce - C 编程语言代码示例

📅  最后修改于: 2022-03-11 15:04:39.860000             🧑  作者: Mango

代码示例1
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 );

    }

}