Woocommerce:以编程方式添加到购物车

时间:2015-04-22 11:33:44

标签: wordpress woocommerce

我有一个销售虚拟产品的网站:基本上是许可证,包含开始和结束日期以及数量。这与woocommerce不太匹配,因此我通过Ajax将所需的表单数据直接发送到服务器,然后用户必须手动结帐以支付费用。

我认为解决这个问题的明显方法是使用wc_create_order。但是,这似乎会创建一个已完成的订单,其状态为“等待付款”。似乎没有办法真正支付订单 - 结帐/购物车页面说明没有订单。

这样做是//used for ui to determine in certain prompts which commands are acceptable var options = []; //the input that the player puts in the ui box var playerInput; //handles user input function uiPrompt () { playerInput = document.getElementById("prompt").value; for (var i = 0; i < options.length; ++i) { if (playerInput == options[i][0]) {break; } console.log(options[i][0]); } } //start menu at the beginning of the game function startMenu () { options = [ ['n', 'l', 'new game', 'load game', 'new', 'load'], ['newGame()', 'loadGame()', 'newGame()', 'loadGame()', 'newGame()', 'loadGame()'] ]; document.getElementById('text').innerHTML = 'RANDOM RPG: Where everything is random! \n (N)ew Game \n (L)oad Game'; } //the new game menu function newGame () { document.getElementById('text').innerHTML = 'You started a new game.'; } startMenu(); 吗?这很痛苦 - 您必须创建并插入帖子,添加帖子元,然后调用add_to_cart。我可以找到丢失的代码片段来做到这一点,但没有明确的文档。我错过了什么吗?

0 个答案:

没有答案
相关问题