1
我新的訂閱付款需要關於訂閱付款的幫助。我正在使用 WC() - > cart-> add_to_cart($ parent_id); 用於將產品添加到購物車。 如何將產品添加到購物車以進行月度或年度定期付款。 我應該發送什麼參數?Woocommerce添加到購物車單月或年度付款
WC() - > cart-> add_to_cart($ parent_id,'yearly'); 還是什麼?
我新的訂閱付款需要關於訂閱付款的幫助。我正在使用 WC() - > cart-> add_to_cart($ parent_id); 用於將產品添加到購物車。 如何將產品添加到購物車以進行月度或年度定期付款。 我應該發送什麼參數?Woocommerce添加到購物車單月或年度付款
WC() - > cart-> add_to_cart($ parent_id,'yearly'); 還是什麼?
訂購間隔在產品頁面中設置。
如果你想訂閱有不同的時間間隔,並希望他們選擇語法必須創建一個訂閱變量和更改在每個變化的時期。
然後,當您添加產品到購物車,你選擇要補充什麼變化
add_to_cart($product_id, $quantity, $variation_id);
這是add_to_cart功能的所有可用參數:
/**
* Add a product to the cart.
*
* @param int $product_id contains the id of the product to add to the cart
* @param int $quantity contains the quantity of the item to add
* @param int $variation_id
* @param array $variation attribute values
* @param array $cart_item_data extra cart item data we want to pass into the item
* @return string|bool $cart_item_key
*/
public function add_to_cart($product_id = 0, $quantity = 1, $variation_id = 0, $variation = array(), $cart_item_data = array()) {
[...]
}
查看完整的文檔在Woocommerce Subscriptions FAQ
你必須首先創建訂閱產品或訂閱。然後我猜你實際上可以使用你的代碼添加它。您可以閱讀更多關於訂閱[這裏](https://docs.woocommerce.com/document/subscriptions/subscription-product-vs-subscription/) –
我已創建訂閱產品 – Ali
我只想知道我應該編碼用於在此功能中添加訂閱期限還是在其他方面添加訂閱期限? WC() - > cart-> add_to_cart($ parent_id,'annual');或WC() - > cart-> add_to_cart($ parent_id,'monthly');或者是什麼? – Ali