WooCommerce - 在客户视图订单页面上添加评论按钮

时间:2016-08-20 09:32:32

标签: php wordpress woocommerce review orders

在我的WooCommerce模板上,“添加评论”功能会显示在单个产品页面上,例如Website link

这对我的客户来说似乎很难。我打算在客户视图订单页面底部移动“添加评论”按钮。

因此,当客户看到订单(“已完成”状态)时,他只需“点击”此新按钮,就会在其单个产品页面上自动更新此购买产品的评论。

我想自定义我的Woocommerce模板:

enter image description here

我在客户视图订单页面底部添加了新按钮 beri testimoni ,代码如下:

<div class="reviews-form">
    <a href="#review_form" class="element-button element-colorbox"><?php _e('Add Review', 'makery'); ?></a>
</div>
<div class="site-popups hidden">
    <div id="review_form">
        <div class="site-popup large">
            <div class="site-form">
                <?php
                $commenter=wp_get_current_commenter();

                $comment_form=array(
                    'title_reply' => '',
                    'title_reply_to' => '',
                    'comment_notes_before' => '',
                    'comment_notes_after' => '',
                    'fields' => array(
                        'author' => '<div class="column fourcol static"><label for="author">'.__('Name', 'makery').'</label></div><div class="eightcol column static last"><div class="field-wrap"><input id="author" name="author" type="text" value="'.esc_attr($commenter['comment_author']).'" size="30" aria-required="true" /></div></div>',
                        'email' => '<div class="column fourcol static"><label for="email">'.__('Email', 'makery').'</label></div><div class="eightcol column static last"><div class="field-wrap"><input id="email" name="email" type="text" value="'.esc_attr($commenter['comment_author_email']).'" size="30" aria-required="true" /></div></div>',
                    ),
                    'label_submit' => __('Kirim', 'makery'),
                    'name_submit' => 'submit',
                    'class_submit' => '',
                    'logged_in_as' => '',
                    'comment_field' => '',
                );

                if(get_option('woocommerce_enable_review_rating')=== 'yes'){
                    $comment_form['comment_field']='<div class="column fourcol static"><label for="rating">'.__('Rating', 'makery').'</label></div>
                    <div class="column eightcol static last"><div class="element-select"><span></span>
                    <select name="rating" id="rating">
                        <option value="">&ndash;</option>
                        <option value="5">'.__('Puas!', 'makery').'</option>
                        <option value="4">'.__('Keren, tapi...', 'makery').'</option>
                        <option value="3">'.__('Bagus', 'makery').'</option>
                        <option value="2">'.__('Lumayan, tapi...', 'makery').'</option>
                        <option value="1">'.__('Jelek!', 'makery').'</option>
                    </select></div></div><div class="clear"></div>';
                }

                $comment_form['comment_field'].= '<textarea id="comment" name="comment" cols="45" rows="6" aria-required="true" placeholder="'.__('Review', 'makery').'"></textarea>';
                comment_form(apply_filters('woocommerce_product_review_comment_form_args', $comment_form));
                ?>
            </div>
        </div>
    </div>
</div>
<!-- /popups -->

注意: 此代码与页面单品上的“添加评论”代码相同。

但是,这会产生一些错误而无效 ......

我做错了什么?
我怎么能解决这个问题?

由于

0 个答案:

没有答案
相关问题