@@ -495,7 +495,19 @@ public function isRewardDropDownEnable()
495495 */
496496 public function isModuleEnabled ()
497497 {
498- return $ this ->getConfig (self ::XML_PATH_LOYALTY_REWARDS_ACTIVE ) ? true : false ;
498+ if ($ this ->getConfig (self ::XML_PATH_LOYALTY_REWARDS_ACTIVE )) {
499+ if (!$ this ->isAutoEnrollmentEnabled ()) {
500+ $ customerId = $ this ->customerSession ->create ()->getCustomerId ();
501+ if ($ customerId ) {
502+ $ zinreloOptedIn = $ this ->getOptInCustomAttributeValue ($ customerId );
503+ if (!$ zinreloOptedIn ) {
504+ return false ;
505+ }
506+ }
507+ }
508+ return true ;
509+ }
510+ return false ;
499511 }
500512
501513 /**
@@ -700,7 +712,7 @@ public function getRedeemRules()
700712 "reward_id " => $ rule ["reward_id " ],
701713 "id " => '' ,
702714 "reward_name " => $ rule ["reward_name " ],
703- "reward_value " => $ rule ["reward_value " ],
715+ "reward_value " => ! empty ( $ rule ["reward_value " ]) ? $ rule [ " reward_value " ] : "" ,
704716 "maximum_redemption_limit " => !empty ($ rule ["extra_parameters " ]["maximum_redemption_limit " ])
705717 ? $ rule ["extra_parameters " ]["maximum_redemption_limit " ] : "" ,
706718 "minimum_redemption_limit " => !empty ($ rule ["extra_parameters " ]["minimum_redemption_limit " ])
@@ -727,6 +739,23 @@ public function getCustomerEmailBySession()
727739 return $ this ->customerSession ->create ()->getCustomer ()->getEmail () ?? '' ;
728740 }
729741
742+ /**
743+ * Get Customer Custom Attribute Value
744+ *
745+ * @return mixed
746+ */
747+ public function getOptInCustomAttributeValue ($ customerId )
748+ {
749+ $ customerData = $ this ->customerRepository ->getById ($ customerId );
750+ $ opt_in_attribute = $ this ->getOptInAttributeCode ();
751+ $ zinreloOptedIn = $ customerData ->getCustomAttribute ($ opt_in_attribute );
752+ if ($ zinreloOptedIn ) {
753+ return $ zinreloOptedIn ->getValue ();
754+ }
755+ return null ;
756+ }
757+
758+
730759 /**
731760 * Get Free Product
732761 *
0 commit comments