2016-11-21 42 views
-1

我想添加一個自定義字段到購物車頁面,並且正如它在documentation中所說,它似乎很容易添加自定義字段以檢出頁面,如運輸和計費。但我想添加一個字段到購物車頁面。 所以,我的網頁上我有woocommerce簡碼:WordPress的 - 解析錯誤:語法錯誤,意外的'*'

[woocommerce_cart] 

我應該增加一個字段到woocommerce車,所以創建子主題是行不通的,從我能讀,因爲這隻會更改其他部分頁面,我需要將該字段添加到woocommerce購物車,但我該怎麼做?

我試過把這個代碼片段添加到我的主題Enfold的函數文件中。

功能,enfold.php:

* Add the field to the checkout 
**/ 
add_action('woocommerce_cart_collaterals', 'my_custom_checkout_field'); 

function my_custom_checkout_field() { 
echo '<div id="my_custom_checkout_field"><h2>'.__('My Field').'</h2>'; 

woocommerce_form_field('my_field_name', array(
'type'   => 'text', 
'class'  => array('my-field-class form-row-wide'), 
'label'  => __('Fill in this field'), 
'placeholder'  => __('Enter something'), 
)); 

echo '</div>'; 

} 

但我得到了一個錯誤:

Parse error: syntax error, unexpected '*' in /nas/content/staging/bokashinorge/wp-content/themes/enfold/functions-enfold.php on line 1795

即使在刪除代碼片斷,並再次更新文件,我仍然得到同樣的錯誤,現在我似乎鎖定了,因爲在刷新時我總是收到錯誤,並且無法編輯儀表板中的任何內容。我該如何解決這個問題,並添加該字段而不會出錯?

+1

似乎你缺少一個'/ *'到*啓動*您的評論 –

回答

0

嘗試在第一線*前加/,像這樣:

/* Add the field to the checkout **/

+0

的問題是,我可以」現在似乎在儀表板中編輯了任何東西。我看到ftp是解決這個問題的唯一方法嗎? – Leff

+0

是的,你必須通過FTP進入你的網絡服務器並編輯這個文件。或者cPanel文件管理器也許。 – Alex

+0

並將該字段添加到購物車頁面將工作,如果我只是編輯我的主題的functions.php文件,就像我在我的問題中做的那樣? – Leff

相關問題