我想要在下单后到达WooCommerce感谢页面时写入文件。我在functions.php中放入了以下内容:
add_action( 'woocommerce_thankyou', 'test_1', 10, 1 );
function test_1(){
//write to a file when this function is run
$contents = date('m/d/Y h:i:s a', time());
file_put_contents('test.txt', $contents);
}
它
我使用的是安装了WordPress的WooCommerce。我注意到调用WordPress API或WooCommerce API会返回一个缓慢的响应时间。
我创建了一个自定义请求句柄,这样我的ajax调用就不会加载整个WordPress来服务端点。自定义请求句柄文件只提供内容和句柄权限。
myajaxhandler.php
<?php
// Force a short-init since we just need core WP, not the entire framework stack
define( 'SHORTINIT', true );
如果用户选择了信用卡支付方式,点击[下单],跳转到银行网站,点击[取消],又跳回到WooCommerce感谢页面,我该如何显示一些自定义的错误信息?
WooCommerce感谢页面模板代码总结如下(以防我知道如何在我的子主题中添加自定义WooCommerce模板):
if ( $order ) : ?>
<?php if ( $order->has_status( 'failed' ) ) : ?>
<p><?php _e( 'Unfortunately your order cannot be pr
我已经向functions.php添加了以下代码,以便在Woocommerce销售报告中添加一个"Sales by postal code“选项卡:
function filter_woocommerce_admin_reports( $reports ) {
$array = array(
'salse_by_post_code' => array(
'title' => 'Sales by postal code',
'description' =>
我有这个代码来添加商店中的产品,但当您单击添加产品时,它们会正确添加。问题是我不想去产品页面。我要他留在店里。
代码是这样的:
/**
* Override loop template and show quantities next to add to cart buttons
*/
add_action('woocommerce_after_shop_loop_item',
'woocommerce_template_single_add_to_cart', 30);
remove_action( 'woocommerce_
我正在制作一个插件,当用户没有足够的点数时,删除Woocommerce order。但是删除wp_delete_post();不起作用。
function delete_order($order)
{
global $post;
$order_id = absint( get_query_var( 'order-pay' ) );
//If the user do not have enough point
if(get_user_bonus_point() < (int)$order->get_total())
我有一个函数可以从WooCommerce获取邮政编码
public function validate_zipcode () {
global $wpdb, $woocommerce;
$sql = ' SELECT location_code FROM ' . $wpdb->prefix. 'woocommerce_shipping_zone_locations ';
$sql .= "WHERE location_code IS NOT NULL";
$zones = $wpdb->g