diff --git a/includes/Order/Hooks.php b/includes/Order/Hooks.php index 1de6fd63fb..1a6dc1fbf6 100644 --- a/includes/Order/Hooks.php +++ b/includes/Order/Hooks.php @@ -54,6 +54,9 @@ public function __construct() { add_action( 'woocommerce_reduce_order_stock', [ $this, 'restore_reduced_order_stock' ] ); add_action( 'woocommerce_reduce_order_stock', [ $this, 'handle_order_notes_for_suborder' ], 99 ); + + // Suborder pdf button + add_filter( 'dokan_my_account_my_sub_orders_actions', [ $this, 'suborder_pdf_invoice_button' ], 10, 2 ); } /** @@ -109,7 +112,7 @@ public function on_order_status_change( $order_id, $old_status, $new_status, $or /** * If `exclude_cod_payment` is enabled, don't include the fund in vendor's withdrawal balance. * - * @since DOKAN_LITE_SINCE + * @since DOKAN_SINCE */ $exclude_cod_payment = 'on' === dokan_get_option( 'exclude_cod_payment', 'dokan_withdraw', 'off' ); @@ -396,7 +399,7 @@ public function restore_reduced_order_stock( $order ) { /** * Handle stock level wrong calculation in order notes for suborder * - * @since DOKAN_LITE_SINCE + * @since DOKAN_SINCE * * @param WC_Order $order * @@ -434,4 +437,23 @@ public function handle_order_notes_for_suborder( $order ) { } } } + + /** + * PDF Invoices & Packing Slips for WooCommerce plugin integration on suborder section. + * + * @since DOKAN_SINCE + * + * @param $actions + * @param $order + * + * @return mixed + */ + public function suborder_pdf_invoice_button( $actions, $order ) { + $woocommerce_all_actions = apply_filters( 'woocommerce_my_account_my_orders_actions', $actions, $order ); + + if ( isset( $woocommerce_all_actions['invoice'] ) ) { + $actions['action'] = $woocommerce_all_actions['invoice']; + } + return $actions; + } }