@@ -835,6 +835,60 @@ public function testCustomerIsNotResubscribedWhenOrderStatusChanges(EndToEndTest
835835 $ I ->apiCheckSubscriberDoesNotExist ($ I , $ result ['email_address ' ]);
836836 }
837837
838+ /**
839+ * Test that the Customer is subscribed to Kit with the Form defined in the Plugin settings
840+ * and the Sequence defined in the Product when a manual order is created, its status is set to processing,
841+ * and the opt in setting is enabled.
842+ *
843+ * @since 2.1.0
844+ *
845+ * @param EndToEndTester $I Tester.
846+ */
847+ public function testOptInWithManualOrder (EndToEndTester $ I )
848+ {
849+ // Enable Integration and define its Access and Refresh Tokens.
850+ $ I ->setupConvertKitPlugin (
851+ $ I ,
852+ subscriptionEvent: 'processing ' ,
853+ subscription: 'form: ' . $ _ENV ['CONVERTKIT_API_FORM_ID ' ],
854+ );
855+
856+ // Create Product.
857+ $ productID = $ I ->wooCommerceCreateSimpleProduct ($ I , 'course: ' . $ _ENV ['CONVERTKIT_API_SEQUENCE_ID ' ]);
858+
859+ // Create Manual Order.
860+ $ result = $ I ->wooCommerceCreateManualOrder (
861+ $ I ,
862+ productID: $ productID ,
863+ productName: 'Simple Product ' ,
864+ orderStatus: 'wc-processing ' ,
865+ optIn: true ,
866+ );
867+
868+ // Confirm that the email address was now added to Kit.
869+ $ subscriber = $ I ->apiCheckSubscriberExists (
870+ $ I ,
871+ emailAddress: $ result ['email_address ' ],
872+ );
873+
874+ // Unsubscribe the email address, so we restore the account back to its previous state.
875+ $ I ->apiUnsubscribe ($ subscriber ['id ' ]);
876+
877+ // Check that the Order's Notes include a note from the Plugin confirming the Customer was subscribed to the Form.
878+ $ I ->wooCommerceOrderNoteExists (
879+ $ I ,
880+ orderID: $ result ['order_id ' ],
881+ noteText: 'Customer subscribed to the Form: ' . $ _ENV ['CONVERTKIT_API_FORM_NAME ' ] . ' [ ' . $ _ENV ['CONVERTKIT_API_FORM_ID ' ] . '] '
882+ );
883+
884+ // Check that the Order's Notes include a note from the Plugin confirming the Customer was subscribed to the Sequence.
885+ $ I ->wooCommerceOrderNoteExists (
886+ $ I ,
887+ orderID: $ result ['order_id ' ],
888+ noteText: 'Customer subscribed to the Sequence: ' . $ _ENV ['CONVERTKIT_API_SEQUENCE_NAME ' ] . ' [ ' . $ _ENV ['CONVERTKIT_API_SEQUENCE_ID ' ] . '] '
889+ );
890+ }
891+
838892 /**
839893 * Deactivate and reset Plugin(s) after each test, if the test passes.
840894 * We don't use _after, as this would provide a screenshot of the Plugin
0 commit comments