hi आप इसे बिलिंग कोड में नीचे दिए गए कोड द्वारा जोड़ सकते हैं
<input type="checkbox" name="is_subscribed"
title="<?php echo $this->__('Sign Up for Newsletter') ?>" value="1" checked="checked" class="checkbox" />
घटना का उपयोग करके checkout_submit_all_after
ग्राहक को न्यूज़लेटर की सदस्यता दें
<global>
<events>
<checkout_submit_all_after> <!-- identifier of the event we want to catch -->
<observers>
<checkout_submit_all_after_handler> <!-- identifier of the event handler -->
<type>singleton</type> <!-- class method call type; valid are model, object and singleton -->
<class>magento52274/observer</class> <!-- observers class alias -->
<method>AssignNewletter</method> <!-- observer's method to be called -->
<args></args> <!-- additional arguments passed to observer -->
</checkout_submit_all_after_handler>
</observers>
</checkout_submit_all_after>
</events>
</global>
और प्रेक्षक कोड है:
public function AssignNewletter($observer) {
$event = $observer->getEvent();
$order = $event->getOrder();
$Quote =$event->getQuote();
if (in_array($Quote()->getCheckoutMethod(), array('register','customer'))):
if (Mage::app()->getFrontController()->getRequest()->getParam('is_subscribed')){
$status = Mage::getModel('newsletter/subscriber')->subscribe($Quote->getBillingAddress()->getCustomerEmail());
}
endif;
}
पूर्ण मॉड्यूल:
Step1: पर config.xml बनाएँ app/code/local/Stackexchange/Magento52274/etc/
और कोड है
<?xml version="1.0"?>
<config>
<modules>
<Stackexchange_Magento52274>
<version>1.0.0</version>
</Stackexchange_Magento52274>
</modules>
<global>
<models>
<magento52274>
<class>Stackexchange_Magento52274_Model</class>
</magento52274>
</models>
<events>
<checkout_submit_all_after> <!-- identifier of the event we want to catch -->
<observers>
<checkout_submit_all_after_handler> <!-- identifier of the event handler -->
<type>singleton</type> <!-- class method call type; valid are model, object and singleton -->
<class>magento52274/observer</class> <!-- observers class alias -->
<method>AssignNewletter</method> <!-- observer's method to be called -->
</checkout_submit_all_after_handler>
</observers>
</checkout_submit_all_after>
</events>
</global>
</config>
चरण 2: बनाने Observer.php
पर app/code/local/Stackexchange/Magento52274/Model/
और कोड है
<?php
class Stackexchange_Magento52274_Model_Observer
{
public function AssignNewletter(Varien_Event_Observer $observer)
{
$event = $observer->getEvent();
$order = $event->getOrder();
$Quote =$event->getQuote();
if (in_array($Quote()->getCheckoutMethod(), array('register','customer'))):
if Mage::app()->getFrontController()->getParam('is_subscribed', false)){
$status = Mage::getModel('newsletter/subscriber')->subscribe($Quote->getBillingAddress()->getEmail());
}
endif;
}
}
Step3: मॉड्यूल बनाएं app/etc/modules/Stackexchange_Magento52274.xml
और कोड है
<?xml version="1.0"?>
<config>
<modules>
<Stackexchange_Magento52274>
<active>true</active>
<codePool>local</codePool>
<version>1.0.0</version>
</Stackexchange_Magento52274>
</modules>
</config>
Step4: और भी billing.phtml
एक पर न्यूजलेटर क्षेत्र जोड़ने की जरूरत है
<input type="checkbox" name="is_subscribed"
title="<?php echo $this->__('Sign Up for Newsletter') ?>" value="1" checked="checked" class="checkbox" />