Noptin_WooCommerce_Product_Purchase_Trigger::get_rule_description( $rule )


Source Source

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

    public function get_rule_description( $rule ) {

        $settings = $rule->trigger_settings;

        // Are we filtering by subscription method?
        if ( empty( $settings['action'] ) || empty( $settings['product_id'] ) ) {
            return __( 'When a subscriber buys a WooCommerce product', 'newsletter-optin-box' );
        }

        $product = wc_get_product( $settings['product_id'] );
		if ( empty( $product ) ) {
			$product = '<span style="color: red;">' . __( 'missing product', 'newsletter-optin-box' ) . '<span>';
        } else {
            $product = esc_html( $product->get_name() );
        }

        if ( 'refund' == $settings['action'] ) {

            if ( ! empty( $settings['first_time'] ) ) {
                return sprintf(
                    __( 'When a first time customer is refunded for %s', 'newsletter-optin-box' ),
                   "<code>$product</code>"
                );
            }

            return sprintf(
                __( 'When a customer is refunded for %s', 'newsletter-optin-box' ),
               "<code>$product</code>"
            );

        }
        
        if ( ! empty( $settings['first_time'] ) ) {
            return sprintf(
                __( 'The first time a subscriber buys %s', 'newsletter-optin-box' ),
               "<code>$product</code>"
            );
        }

        return sprintf(
            __( 'When a subscriber buys %s', 'newsletter-optin-box' ),
           "<code>$product</code>"
        );

    }

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