【发布时间】:2018-09-27 13:03:02
【问题描述】:
大家好,我通过搜索和寻找解决方案来对我在 woocommerce 上的结帐进行一些编辑来管理。
到目前为止,我已经成功了,所以我跳过了购物车/购物篮,直接去结账,并重命名了提交的订单说明。使用下面的功能代码。
我正在努力解决的是如何将订单备注字段移动到订单评论上方。我知道我需要使用这个 woocommerce_checkout_before_order_review 但我不确定如何。有什么帮助会很棒吗?
add_filter('woocommerce_add_to_cart_redirect', 'themeprefix_add_to_cart_redirect');
function themeprefix_add_to_cart_redirect() {
global $woocommerce;
$checkout_url = wc_get_checkout_url();
return $checkout_url;
}
//Add New Pay Button Text
add_filter( 'woocommerce_product_single_add_to_cart_text', 'themeprefix_cart_button_text' );
add_filter( 'woocommerce_product_add_to_cart_text', 'themeprefix_cart_button_text' );
function themeprefix_cart_button_text() {
return __( 'Add to cart & go to checkout', 'woocommerce' );
}
// Place this code in your theme's functions.php file
// Hook in
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
// Our hooked in function - $fields is passed via the filter!
function custom_override_checkout_fields( $fields ) {
$fields['order']['order_comments']['required'] = true;
return $fields;
}
add_filter( 'woocommerce_checkout_fields', 'filter_checkout_fields' );
function filter_checkout_fields( $fields ) {
$fields['order']['order_comments']['maxlength'] = 160;
$fields['order']['order_comments']['label'] = '<h2>Personalized Message</h2>';
$fields['order']['order_comments']['placeholder'] = 'Add message here';
return $fields;
}
【问题讨论】:
-
订单注释不能通过钩子删除,因为它们位于 Woocommerce 模板
checkout/form-shipping.php中......所以你应该需要override Woocommerce templates via your active theme 删除从checkout/form-shipping.php到checkout/review-order.php的整个代码块......
标签: php wordpress woocommerce