Noptin_WooCommerce_Product_Purchase_Trigger::is_rule_valid_for_args( $rule,  $args,  $subscriber,  $action )


Source Source

File: includes/automation-rules/triggers/class-noptin-woocommerce-product-purchase-trigger.php

    public function is_rule_valid_for_args( $rule, $args, $subscriber, $action ) {
        $settings = $rule->trigger_settings;

        // Ensure that we have an action for this event.
        if ( empty( $settings['action'] ) || $settings['action'] !== $args['action'] ) {
            return false;
        }

        // Confirm the products match.
        if ( empty( $settings['product_id'] ) || $settings['product_id'] != $args['product_id'] ) {
            return false;
        }

        // Are we firering for new buyers only?
        if ( ! empty( $settings['first_time'] ) ) {

            // Fetch the user associated with the order.
            $user = $this->bridge->get_order_customer_user_id( $args['order_id'] );
            if ( empty( $user ) ) {
                $user = $this->bridge->get_order_customer_email( $args['order_id'] );
            }

            return $this->bridge->get_product_purchase_count( $user, $args['product_id'] ) === 1;

        }

        return true;

    }

Top ↑

User Contributed Notes User Contributed Notes

30 day money back guarantee
Safe & Secure online payment
Custom CSS Slide Example
Custom Animation Example
Default Animation