’ . __( 'Numer NIP’, 'woocommerce’ ) . ’: ’ . get_post_meta( $order->id, 'nip_number’, true ) . ’
’; } add_filter( 'woocommerce_email_order_meta_keys’, 'pracowniaperuna_add_NIP_to_emails’ ); function pracowniaperuna_add_NIP_to_emails( $keys ) { $keys[’Numer NIP’] = 'nip_number’; return $keys; }
//Filtrowanie kosztów wysyłki
add_filter( 'woocommerce_package_rates’, 'pracowniaperuna_hide_shipping_method’, 10, 2 );
function pracowniaperuna_hide_shipping_method( $rates, $package )
{
if ( is_admin() && ! defined( 'DOING_AJAX’ ) )
return;
/*****************KLASA WYSYŁKI**************************/
$class1 = 112;
/********************************************************/
/*****************METODA WYSYŁKI*************************/
$method_key_ids = array(’flat_rate:20′);
/********************************************************/
foreach( $package[’contents’] as $item ) {
if( $item[’data’]->get_shipping_class_id() == $class1 ){
foreach( $method_key_ids as $method_key_id ){
unset($rates[$method_key_id]);
}
continue;
}
else if( $item[’data’]->get_shipping_class_id() == $class2 ){
foreach( $method_key_ids as $method_key_id ){
unset($rates[$method_key_id]);
}
break;
}
}
return $rates;
}
add_filter( 'woocommerce_package_rates’, 'pracownia_peruna_hide_shipping_method’, 10, 2 );
function pracownia_peruna_hide_shipping_method( $rates, $package )
{
if ( is_admin() && ! defined( 'DOING_AJAX’ ) )
return;
/*****************KLASA WYSYŁKI**************************/
$class1 = 113;
$class1 = 114;
$class1 = 115;
$class1 = 116;
$class1 = 117;
/********************************************************/
/*****************METODA WYSYŁKI*************************/
$method_key_ids = array(’flat_rate:14′);
/********************************************************/
foreach( $package[’contents’] as $item ) {
if( $item[’data’]->get_shipping_class_id() == $class1 ){
foreach( $method_key_ids as $method_key_id ){
unset($rates[$method_key_id]);
}
continue;
}
else if( $item[’data’]->get_shipping_class_id() == $class2 ){
foreach( $method_key_ids as $method_key_id ){
unset($rates[$method_key_id]);
}
break;
}
}
return $rates;
}// Przeniesienie opisu kategorii
remove_action( 'woocommerce_archive_description’, 'woocommerce_taxonomy_archive_description’, 10 );
add_action( 'woocommerce_after_shop_loop’, 'woocommerce_taxonomy_archive_description’, 100 );//nowy kod NIP
add_filter( 'woocommerce_checkout_fields’ , 'pracowniaperuna_add_NIP_to_checkout_page’ );
function pracowniaperuna_add_NIP_to_checkout_page( $fields ) {
$fields[’billing’][’nip_number’] = array(
'label’ => 'Numer NIP’,
'placeholder’ =>’Jeśli chcesz otrzymać fakturę, podaj swój numer NIP’,
'class’ => array( 'form-row-wide’) ,
'priority’ => $fields[’billing’][’billing_company’][’priority’] + 1,
);
return $fields;
}
add_action( 'woocommerce_checkout_update_order_meta’, 'pracowniaperuna_save_NIP’ );
function pracowniaperuna_save_NIP( $order_id ) {
if ( ! empty( $_POST[’nip_number’] ) ) {
update_post_meta( $order_id, 'nip_number’, sanitize_text_field( $_POST[’nip_number’] ) );
}
}
add_action( 'woocommerce_admin_order_data_after_billing_address’, 'pracowniaperuna_add_NIP_to_admin_area’, 10, 1 );
function pracowniaperuna_add_NIP_to_admin_area( $order ) {
echo ’