wordpress - WP 全部导出 : how to pass exported data through PHP function

标签 wordpress woocommerce wpallimport

我正在尝试在 WP All Export 中构建自定义导出列,但我无法获得我想要实现的目标。我需要“付款”栏,如果付款方式是货到付款,我需要在其中填写实际订单总额。否则应该返回0( express 公司要求)。我尝试修改下面的代码,但它不起作用。

<?php
function cod_payment( $order_id ) {
    $total = get_total();
    $method = get_payment_method();
    if($method == "cod") {
        return $total;
    } else {
        return "0";
    }
}
?>

Edit Export Field dialogue in WP All Export

最佳答案

你可以做这样的事情。选择自定义导出字段在文本区域中添加函数调用

[cod_payment({Payment Method},{Order Total})]

最后将 PHP 添加到函数编辑器中(确保保存)

<?php
function cod_payment( $method, $total ) {

    if($method == "cod") {
        return $total;
    } else {
        return "0";
    }
}
?>

请记住方法名称可能不正确。

Screenshot

关于wordpress - WP 全部导出 : how to pass exported data through PHP function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66944625/

相关文章:

php - 获取单独订单的税金总额和税级

php - 获取 Woocommerce 3 中的订单费用项目详细信息

php - 如何提高 WpAllImport 更新价格的速度?

wordpress - Woo-commerce - get_date_created()- 给出空值

xml - 您如何在WP ALL IMPORT中为选定的高级自定义字段格式化xpath值?

mysql - WordPress 插件样板表创建

MySQL 查询超时 : (70100): Query execution was interrupted

php - 在 WordPress 中注册后向用户发送激活链接

html - 在移动 View (CSS) 中将内容和图像居中