门牌号码在运费字段中显示两次。我不确定是什么原因造成的。
这就是我的functions.php目前在子主题文件夹中的样子。其中一条线可能导致这种情况吗?
<?php
add_filter('gettext', 'translate_reply');
add_filter('ngettext', 'translate_reply');
function translate_reply($translated) {
$translated = str_ireplace('Order number', 'Ordernummer', $translated);
$translated = str_ireplace('Bestelnummer:', 'Ordernummer:', $translated);
$translated = str_ireplace('Your order', 'Uw bestelling', $translated);
$translated = str_ireplace('Based on', 'Gebaseerd op', $translated);
$translated = str_ireplace('Show', 'Bekijk', $translated);
$translated = str_ireplace('Doorgaan naar afrekenen', 'Doorgaan naar volgende stap', $translated);
$translated = str_ireplace('Add', 'Toevoegen', $translated);
$translated = str_ireplace('Your', 'Uw', $translated);
$translated = str_ireplace('Je winkelmand is momenteel leeg.', 'Uw winkelmand is momenteel leeg.', $translated);
$translated = str_ireplace('There are no reviews yet.', 'Er zijn nog geen reviews.', $translated);
$translated = str_ireplace('Be the first to review', 'Geef als eerste een review over', $translated);
$translated = str_ireplace('Shipping Details', 'Verzend gegevens', $translated);
$translated = str_ireplace('new-price', 'Verzend gegevens', $translated);
$translated = str_ireplace('new price', 'Verzend gegevens', $translated);
$translated = str_ireplace('New price', 'Verzend gegevens', $translated);
$translated = str_ireplace('VAT', 'BTW', $translated);
$translated = str_ireplace('overall', 'Gemiddeld', $translated);
$translated = str_ireplace('Name', 'Naam', $translated);
$translated = str_ireplace('Assortiment Categories', 'Categoriën', $translated);
$translated = str_ireplace('Bedankt. Wij hebben uw bestelling ontvangen', 'Bedankt. Wij hebben uw bestelling/aanvraag ontvangen. U ontvangt z.s.m.
een bevestiging hiervan in uw mailbox.</br> <b>Let op</b>, heeft u deze mail niet ontvangen, controleer dan uw "ongewenste post" map (spam folder).', $translated);
return $translated;
}
// function custom_add_to_cart_redirect() {
// return 'https://www.prikkabelled.nl/overzicht-bestelling/';
// }
// add_filter( 'woocommerce_add_to_cart_redirect', 'custom_add_to_cart_redirect' );
// Display 24 products per page. Goes in functions.php
add_filter( 'loop_shop_per_page', function ( $cols ) {
return - 1;
} );
/**
* Plugin Name: WooCommerce Product Bundles - Default Bundled Item Quantity Override
* Plugin URI: http://www.woothemes.com/products/composite-products/
* Description: Use this snippet to override the initial quantity value of a bundled item (by default equal to the minimum quantity).
* Version: 1.0
* Author: SomewhereWarm
* Author URI: http://www.somewherewarm.net/
* Developer: Manos Psychogyiopoulos
*
* Requires at least: 3.8
* Tested up to: 4.1
*
* Copyright: © 2015 Manos Psychogyiopoulos (psyx@somewherewarm.net).
* License: GNU General Public License v3.0
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
//global array to reposition the elements to display as you want (e.g. kept 'title' before 'first_name' )
$wdm_address_fields = array(
'country',
'company',
'last_name',
'first_name',
'address_1',
'housenumber',
'housenr-ad',
'city',
'postcode'
);
//global array only for extra fields
$wdm_ext_fields = array('title', 'address_4');
add_filter( 'woocommerce_default_address_fields' , 'wdm_override_default_address_fields' );
function wdm_override_default_address_fields( $address_fields ){
$temp_fields = array();
$address_fields['address_1']['placeholder'] = '';
$address_fields['address_1']['label'] = __('Street', 'woocommerce');
$address_fields['address_2']['placeholder'] = '';
$address_fields['address_2']['label'] = __('Building', 'woocommerce');
$address_fields['housenumber'] = array(
'label' => __('Huisnr.', 'woocommerce'),
'placeholder'=> '',
'required' => true,
'class' => array('form-row-wide', 'address-field'),
'type' => 'number'
);
$address_fields['housenr-ad'] = array(
'label' => __('Toevoeging', 'woocommerce'),
'placeholder'=> '',
'required' => true,
'class' => array('form-row-wide', 'address-field'),
'type' => 'text'
);
$address_fields['address_4'] = array(
'label' => __('Area', 'woocommerce'),
'placeholder'=> '',
'class' => array('form-row-wide', 'address-field'),
'type' => 'text'
);
global $wdm_address_fields;
foreach($wdm_address_fields as $fky){
$temp_fields[$fky] = $address_fields[$fky];
}
$address_fields = $temp_fields;
return $address_fields;
}
add_filter('woocommerce_formatted_address_replacements', 'wdm_formatted_address_replacements', 99, 2);
function wdm_formatted_address_replacements( $address, $args ){
$address['{address_1}'] = $args['address_1'] . " " . $args['housenumber'] . $args['address_2'] . " " . $args['housenr-ad'];
return $address;
}
// add_filter('woocommerce_formatted_address_replacements', 'wdm_formatted_address_replacements2', 99, 2);
// function wdm_formatted_address_replacements2( $address, $args ){
// $address['{address_2}'] = $args['address_2'] . " " . $args['postcode'] . " " . $args['Plaats']; //reposition to display as it should be
// return $address;
// }
add_filter( 'woocommerce_order_formatted_billing_address', 'wdm_update_formatted_billing_address', 99, 2);
function wdm_update_formatted_billing_address( $address, $obj ){
global $wdm_address_fields;
if(is_array($wdm_address_fields)){
foreach($wdm_address_fields as $waf){
$address[$waf] = $obj->{'billing_'.$waf};
}
}
return $address;
}
add_filter( 'woocommerce_order_formatted_shipping_address', 'wdm_update_formatted_shipping_address', 99, 2);
function wdm_update_formatted_shipping_address( $address, $obj ){
global $wdm_address_fields;
if(is_array($wdm_address_fields)){
foreach($wdm_address_fields as $waf){
$address[$waf] = $obj->{'shipping_'.$waf};
}
}
return $address;
}
?>
<?php
add_filter('woocommerce_my_account_my_address_formatted_address', 'wdm_my_account_address_formatted_address', 99, 3);
function wdm_my_account_address_formatted_address( $address, $customer_id, $name ){
global $wdm_address_fields;
if (is_array($wdm_address_fields)){
foreach($wdm_address_fields as $waf){
$address[$waf] = get_user_meta( $customer_id, $name . '_' . $waf, true );
}
}
return $address;
}
?>
<?php
add_filter('woocommerce_admin_billing_fields', 'wdm_add_extra_customer_field');
add_filter('woocommerce_admin_shipping_fields', 'wdm_add_extra_customer_field');
function wdm_add_extra_customer_field( $fields ){
$fields = wdm_override_default_address_fields( $fields );
global $wdm_ext_fields;
if(is_array($wdm_ext_fields)){
foreach($wdm_ext_fields as $wef){
$fields[$wef]['show'] = false; //hide the way they are display by default as we have now merged them within the address field
}
}
return $fields;
}
/* Exclude Category from Shop*/
add_filter( 'get_terms', 'get_subcategory_terms', 10, 3 );
function get_subcategory_terms( $terms, $taxonomies, $args ) {
$new_terms = array();
// if a product category and on the shop page
if ( in_array( 'product_cat', $taxonomies ) && ! is_admin() && is_shop() ) {
foreach ( $terms as $key => $term ) {
if ( ! in_array( $term->slug, array( 'overige-lampen') ) ) {
$new_terms[] = $term;
}
}
$terms = $new_terms;
}
return $terms;
}
?>
<?php
function theme_js() {
wp_enqueue_script( 'electro-custom', get_stylesheet_directory_uri() . '/assets/js/electro-custom.js', array( 'jquery' ), '1.0', true );
}
add_action('wp_enqueue_scripts', 'theme_js');
?>
<?php
// remove Order Notes from checkout field in Woocommerce
add_filter( 'woocommerce_checkout_fields' , 'alter_woocommerce_checkout_fields' );
function alter_woocommerce_checkout_fields( $fields ) {
unset($fields['order']['order_comments']);
return $fields;
}
?>
答案 0 :(得分:1)
更改您的代码:
function wdm_formatted_address_replacements( $address, $args ){
$address['{address_1}'] = $args['address_1'] . " " . $args['housenumber'] . $args['address_2'] . " " . $args['housenr-ad'];
return $address;
}
要:
function wdm_formatted_address_replacements( $address, $args ){
$address['{address_1}'] = $args['address_1'] . $args['address_2'] . " " . $args['housenr-ad'];
return $address;
}
希望它会起作用!!!