Zakázání automatického generování faktur
Tento obsah zatím není dostupný ve vašem jazyce.
Pokud potřebujete za určitých podmínek zakázat automatické generování faktur (např. pro určité produkty, zákazníky nebo stavy), můžete využít filtr wpify_woo_fakturoid_disable_auto_invoicing.
Filtr pro zakázání automatického generování
Section titled “Filtr pro zakázání automatického generování”apply_filters( 'wpify_woo_fakturoid_disable_auto_invoicing', $disabled, $order, $wc_order, $document_type );Parametry filtru
Section titled “Parametry filtru”| Parametr | Typ | Popis |
|---|---|---|
$disabled | bool | Výchozí hodnota je false (generování povoleno) |
$order | OrderModel | Model objednávky s Fakturoid daty |
$wc_order | WC_Order | WooCommerce objednávka |
$document_type | string | Typ dokumentu: proforma, invoice, correction |
Příklady použití
Section titled “Příklady použití”Zakázání pro určitou kategorii produktů
Section titled “Zakázání pro určitou kategorii produktů”Toto nastavení nelze provést v administraci - použijte filtr.
/** * Disable auto invoicing for specific product category * * @param bool $disabled Whether auto invoicing is disabled * @param OrderModel $order Order model * @param WC_Order $wc_order WC order * @param string $document_type Document type * * @return bool */function disable_invoicing_for_category( $disabled, $order, $wc_order, $document_type ): bool { foreach ( $wc_order->get_items() as $item ) { $product = $item->get_product(); if ( $product && has_term( 'sluzby', 'product_cat', $product->get_id() ) ) { return true; // Zakázat generování pro kategorii "sluzby" } } return $disabled;}add_filter( 'wpify_woo_fakturoid_disable_auto_invoicing', 'disable_invoicing_for_category', 10, 4 );Zakázání pro konkrétní platební metodu
Section titled “Zakázání pro konkrétní platební metodu”Toto lze nastavit i v administraci - stačí u dané platební metody nevybrat žádný stav pro generování. Filtr použijte pokud potřebujete složitější logiku.
/** * Disable auto invoicing for specific payment method * * @param bool $disabled Whether auto invoicing is disabled * @param OrderModel $order Order model * @param WC_Order $wc_order WC order * @param string $document_type Document type * * @return bool */function disable_invoicing_for_payment_method( $disabled, $order, $wc_order, $document_type ): bool { // Zakázat automatické generování pro platby na dobírku if ( $wc_order->get_payment_method() === 'cod' ) { return true; } return $disabled;}add_filter( 'wpify_woo_fakturoid_disable_auto_invoicing', 'disable_invoicing_for_payment_method', 10, 4 );Zakázání pouze pro proformy
Section titled “Zakázání pouze pro proformy”Toto lze nastavit i v administraci - stačí u platebních metod nevybrat žádný stav pro generování proform. Filtr použijte pro globální zakázání bez ohledu na nastavení.
/** * Disable auto proforma generation * * @param bool $disabled Whether auto invoicing is disabled * @param OrderModel $order Order model * @param WC_Order $wc_order WC order * @param string $document_type Document type * * @return bool */function disable_auto_proforma( $disabled, $order, $wc_order, $document_type ): bool { // Zakázat pouze automatické generování proform if ( $document_type === 'proforma' ) { return true; } return $disabled;}add_filter( 'wpify_woo_fakturoid_disable_auto_invoicing', 'disable_auto_proforma', 10, 4 );Zakázání pro B2B zákazníky
Section titled “Zakázání pro B2B zákazníky”Toto nastavení nelze provést v administraci - použijte filtr.
/** * Disable auto invoicing for B2B customers (with company/VAT) * * @param bool $disabled Whether auto invoicing is disabled * @param OrderModel $order Order model * @param WC_Order $wc_order WC order * @param string $document_type Document type * * @return bool */function disable_invoicing_for_b2b( $disabled, $order, $wc_order, $document_type ): bool { // Zakázat pro zákazníky s IČO nebo DIČ (B2B) if ( $wc_order->get_billing_company() || $wc_order->get_meta( '_billing_ic' ) ) { return true; } return $disabled;}add_filter( 'wpify_woo_fakturoid_disable_auto_invoicing', 'disable_invoicing_for_b2b', 10, 4 );Kde umístit kód
Section titled “Kde umístit kód”Vlastní funkci můžete vložit buď do tzv. child šablony nebo pomocí pluginu Code Snippets.