OrderBook充满了买卖订单.更新,新订单可以执行交易.
我似乎无法找到任何实施的例子.
我们可以给每个订单一个id,并逐个checkExecute订单.但我们想要的东西可以扩展到成千上万的活跃订单.
我们可以对价格进行排序以获得将要执行的订单(因为它们重叠).但我们必须小心,只按订单收到的顺序执行:)
思考?
如何使用产品ID获取产品说明或产品对象.
$order = new WC_Order($order_id);
foreach ($order->get_items() as $item) {
$product_description = get_the_product_description($item['product_id']); // is there any method can I use to fetch the product description?
}
Run Code Online (Sandbox Code Playgroud)
上面的代码扩展了类WC_Payment_Gateway
任何帮助将不胜感激.
我正在尝试在WooCommerce订单页面中添加自定义订单操作.
我想在WooCommerce中的批量订单操作下拉列表中添加两个新选项
在这方面的任何帮助都非常感谢.
我想将WooCommerce订单状态从"已完成"重命名为"已收到订单".我可以编辑下面wc-order-functions.php中的脚本,但我不想修改任何核心文件或使用插件.
是否可以使用子主题functions.php文件中的脚本覆盖woocoomerce函数?
function wc_get_order_statuses() {
$order_statuses = array(
'wc-pending' => _x( 'Pending Payment', 'Order status', 'woocommerce' ),
'wc-processing' => _x( 'Processing', 'Order status', 'woocommerce' ),
'wc-on-hold' => _x( 'On Hold', 'Order status', 'woocommerce' ),
'wc-completed' => _x( 'Completed', 'Order status', 'woocommerce' ),
'wc-cancelled' => _x( 'Cancelled', 'Order status', 'woocommerce' ),
'wc-refunded' => _x( 'Refunded', 'Order status', 'woocommerce' ),
'wc-failed' => _x( 'Failed', 'Order status', 'woocommerce' ),
);
return apply_filters( 'wc_order_statuses', $order_statuses );
}
Run Code Online (Sandbox Code Playgroud) 我正在使用WooCommerce创建一个在线商店,我正在添加一个功能,它将更新我的数据库的奖励点absract-wc-payment-gateway.php.
这是我在做的事情:
place order按钮,然后该方法将获得用户奖励积分并减去奖励积分get-total(),然后更新到数据库并转到感谢页面.这是我的代码.它将在用户单击下订单按钮时运行:
global $woocommerce;
$order = new WC_Order($order_id);
$total = $order->get_total();
$bonusPoint -= (int)$total; //minus total price and calculate the latest bonus point
$updateSql = "UPDATE userdata02 SET bonusPoint ='" .$bonusPoint. "' WHERE userID = 2147483647";
mysqli_query($link, $updateSql);// update to an int column
if(mysqli_query($link, $updateSql)) {
echo "Record updated successfully";
} else {
echo "Error update record: <>" . mysqli_error($link);
}
Run Code Online (Sandbox Code Playgroud)
用户单击"放置"按钮时调用该方法:
public function get_return_url( $order = null ) …Run Code Online (Sandbox Code Playgroud) 我需要检查一下客户是否在WooCommerce中购买了特定产品.
情况是这样的:除非客户在较早时间购买产品"a"或"b",否则客户不能购买产品"c","d","e".
如果客户较早购买了产品"a"或"b",则激活产品"c","d"和"e"的购买按钮,并允许他们购买.
如果他们之前没有购买"a"或"b",他们将不被允许购买"c","d","e"并且购买按钮被停用.
我怎样才能做到这一点?
谢谢.
我已经通过function.php为我的产品页面创建了一个自定义保修字段.
add_action( 'woocommerce_product_options_general_product_data', 'test_custom_fields' );
function test_custom_fields() {
// Print a custom text field
woocommerce_wp_text_input( array(
'id' => '_warranty',
'label' => 'i.e. 15 years',
'description' => '',
'desc_tip' => 'true',
'placeholder' => 'i.e. 15 years'
) );
}
add_action( 'woocommerce_process_product_meta', 'test_save_custom_fields' );
function test_save_custom_fields( $post_id ) {
if ( ! empty( $_POST['_warranty'] ) ) {
update_post_meta( $post_id, '_warranty', esc_attr( $_POST['_warranty'] ) );
}
}
Run Code Online (Sandbox Code Playgroud)
我想在管理订单页面的自生成自定义字段中"复制"带有键和值的自定义字段,具体取决于购物车/订单中的产品(无插件).
因此,通过订单页面上的这个自定义字段,我终于可以使用WooCommerce PDF Invoice插件在我的pdf发票中显示"保修".
另一种解释:
{{_warranty}}WooCommerce PDF Invoice插件显示"保修期:15年"非常感谢您的帮助.
我刚刚测试了以下案例: …
目前,Google Play订单ID具有以下格式:GPA.XXXX-XXXX-XXXX-XXXXX
以前,它们类似于:{merchant_id}.{order_id_number}-在所有商家帐户中都非常独特。
但是,现在,我对新的“ GPA ...”格式中的订单ID的唯一性表示怀疑。在这里,我确切地说的是GLOBAL唯一性(在所有帐户中),而不是在一个特定帐户中的唯一性。
那么,它们在全球范围内是否唯一?我找不到有关的信息...
谢谢!
我正在尝试获取订单的订单项.
我这样做:
$order = new WC_Order(147);
foreach ($order->get_items() as $key => $lineItem) {
print_r('<pre>----');
print_r($lineItem);
print_r('----</pre>');
}
Run Code Online (Sandbox Code Playgroud)
我可以看到我需要的所有数据,但数组显示:
[meta_data:protected] => Array
Run Code Online (Sandbox Code Playgroud)
如何访问此数组以获取值?
谢谢.
我希望通过订单获得客户的"mycred"余额,同时使用WP ALL Export将客户余额根据订单导出到电子表格.它实际上可能很简单.我可以获得订单ID,但不能获得客户ID
以下是我正在测试的是否可以获得客户ID:
function get_customeruserid($value)
{
global $woocommerce, $post;
$order = new WC_Order($post->ID);
$order_id = $order->get_order_number();
$customer = new WC_Customer($post->ID);
$user_id = $customer->get_ID();
$value = $user_id;
return $value;
}
Run Code Online (Sandbox Code Playgroud)
返回0.
但是,通过这样做,我可以轻松地获得订单号:
function get_customerorderid($value)
{
global $woocommerce, $post;
$order = new WC_Order($post->ID);
$order_id = $order->get_order_number();
$value = $order_id;
return $value;
}
Run Code Online (Sandbox Code Playgroud)
这将返回客户的订单号,这个订单号很棒,但只有一半的战斗.我现在想要客户ID,所以我打电话给mycred余额函数来显示他们的余额.
有任何想法吗?我是php的新手,可能非常糟糕.
orders ×10
woocommerce ×8
wordpress ×8
php ×7
product ×3
android ×1
class ×1
customer ×1
e-commerce ×1
finance ×1
google-play ×1
price ×1