6

为了通过 WooCommerce 为培训视频创建按观看次数付费的网站,我正在使用“购买备注字段”在订单完成后发送一封电子邮件,其中包含指向视频页面的超链接。这工作正常,但如果您访问我的帐户页面,客户将无法访问“我的帐户”并在一个地方查看他们的所有链接,因为他们可以使用“可用下载”。

我想在 my-account.php 页面的表格中显示两个额外的字段,“产品(项目)名称”和“购买说明”。目前标准表中有“订单”、“运费”、“总计”和“状态”4个字段。

由于我没有使用运输选项(只是一个虚拟产品),我想将此字段更改为产品(项目)名称。如前所述,我想添加“购买备注”字段(这将在付款完成后显示我的视频网址)重要的是,此购买备注字段只能在项目完成后显示。它已经在 order-details.php 页面中执行此操作,但我希望在 my-accounts.php 页面的表中包含此内容

order-details.php 字段中此购买备注字段的当前代码为:

// Show any purchase notes
            if ($order->status=='completed' || $order->status=='processing') :
                if ($purchase_note = get_post_meta( $_product->id, '_purchase_note', true)) :
                    echo '<tr class="product-purchase-note"><td colspan="3">' . apply_filters('the_content', $purchase_note) . '</td></tr>';
                endif;
            endif;

        endforeach;
    endif;

    do_action( 'woocommerce_order_items_table', $order );
    ?>

谁能告诉我我需要在 my-account.php 中更改什么以完成此页面中的这两个额外字段?

4

1 回答 1

3

my-account.php is calling to several other templates, you need my-orders.php. Place a copy in your theme folder to make it update proof.

I am assuming you are using 1.6.6 here, because the my account page has changed from 2.0 and doesn't include the shipping address any longer.

remove line 50, which shows the shipping address. You can edit/replace this and call your purchase note with the following code:

get_post_meta( $order->id, '_purchase_note', true)

then you can get the product name (from your question I'm assuming you only have one product per order?):

foreach($order->get_items() as $item) {
    $product_name = $item['name'];
}

then simply call $product_name in an extra column (copy/paste/edit code another column)

于 2013-04-03T21:23:14.113 回答