Viac číselných rád faktúr podľa produktu

[ad_1]

Dobrý deň,

ID číselníka môžete zmeniť pomocou filtra sf_invoice_data. Príklad nižšie zmení číselník, ak sú v košíku iba produkty s 20% DPH. Podobne môžete filter použiť na zmenu podľa kategórií produktov v košíku alebo podľa akýchkoľvek iných kritérií, ktoré potrebujete.

function my_invoice_data($invoice_data, $order, $type) {
$rates = array();
foreach ( $order->get_items('tax') as $item_id => $item ) {
$tax_rate_id = $item->get_rate_id();
$rates[] = WC_Tax::get_rate_percent_value( $tax_rate_id );
}

if ( empty( array_diff($rates, array(20) ) ) ) {
$invoice_data['sequence_id'] = "12345";
}

return $invoice_data;
}
add_filter('sf_invoice_data', 'my_invoice_data', 10, 3);

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer