diff --git a/ordernumbers_woocommerce.php b/ordernumbers_woocommerce.php index 82a2ff4f2ad85bf7a75afb8bc55588ddeea4dcf2..df655f9356a65008e6a3ce40fa70ce2e2edcceb8 100644 --- a/ordernumbers_woocommerce.php +++ b/ordernumbers_woocommerce.php @@ -65,6 +65,9 @@ class OpenToolsOrdernumbers extends OpenToolsOrdernumbersBasic { // Custom table widget for custom variable definitions: Hooks for creating and storing values add_action( 'woocommerce_admin_field_ordernumber_variables', array( $this, 'admin_field_variables' ) ); add_action( 'pre_update_option_ordernumber_variables', array( $this, 'update_option_variables')); + + // SUPPORT FOR BUILT-IN PLUGINS AND PAYMENT METHODS: + $this->paypal_invoicenumber_init(); // THIRD-PARTY PLUGIN SUPPORT // Install hooks for third-party plugin support: @@ -330,6 +333,18 @@ class OpenToolsOrdernumbers extends OpenToolsOrdernumbersBasic { $reps = apply_filters( 'opentools_ordernumber_replacements', $reps, $details, $nrtype); } + +// PAYPAL SUPPORT + protected function paypal_invoicenumber_init() { + add_filter ('woocommerce_paypal_args', array( &$this, 'paypal_arguments'), 10, 2/*<= Also get the order object! */); + } + + public function paypal_arguments($vals, $order) { + if ($this->invoicenumbers_activated()) { + $vals['invoice'] = $this->get_or_create_number($order->order_id, $order, 'invoice'); + } + return $vals; + } // THIRD-PARTY PLUGIN SUPPORT