我的第一个插件需要一些帮助。它不是一个很大的插件,由一个小的设置页面和3个文本字段组成,这些文本字段显示在woocommerce签出页面上,带有一些css。
不过我有一点进退两难。我只想在字段有显示内容时显示它们。当它们为空时,它将显示背景css样式,并且在单击时仍会显示。我只想在字段为空时不显示它。
在插件的公共文件夹中,我得到了这个。我希望有人能为我解释一下
// first button below billing form
add_action(\'woocommerce_after_checkout_billing_form\', \'show_my_message\');
function show_my_message() {
$wc_checkout_message_settings = get_option(\'wc_checkout_message_settings\');
echo $wc_checkout_message_settings[wc_checkout_message_text_field_0];
echo \'<br>\';
echo $wc_checkout_message_settings[wc_checkout_message_text_field_1];
}
// second set of buttons linking to payment only section
add_action(\'woocommerce_review_order_before_payment\', \'show_new_message\');
function show_new_message(){
$wc_checkout_message_settings = get_option(\'wc_checkout_message_settings\');
echo $wc_checkout_message_settings[wc_checkout_message_text_field_2];
}