错误类woocommerce显示产品可下载链接

时间:2016-10-25 18:28:10

标签: php wordpress woocommerce

我创建了一个在创建产品和发送电子邮件时显示可下载文件URL的功能。 我使用的是课程WC_Product,但我认为这是不正确的,因为收到的电子邮件是我在变量$ downloads中打印"Array"

我的功能:

add_action('draft_to_publish', 'my_product_add');

function my_product_add($post)
{
    if ($post->post_type == "product") {
        $productId = $post->ID;

        $post_title = get_the_title($post_id);
        $tld_prod_url = esc_url(get_permalink($post_id));
        $subject = "Product Added Notification";

        $product = new WC_Product($post_id);
        $downloads.= $product->get_files();

        $to = "me@test.com";
        $body.= "The following product was added: \n\n" . $post_title . "\n" . $tld_prod_url . "\n" . $downloads . "\n\nThanks,\n";
        wp_mail($to, $subject, $body);
    }
}

0 个答案:

没有答案