I am working with Magento, in which I need to require that, if any customer signs up, he/she must be automatically be subscribed to the newsletter.
For instance, in the admin site, if we edit a customer, we get the newsletter checkbox for "Subscribed to Newsletter?". I want that check box to always be checked.
Please help me out.
One small thing : Check this is legal in the territory you are deploying in.
For instance, several legislations insist marketing emails must default to 'Opt In' not 'Opt Out' - this is likely why Magento has the default set as is.
It is also accepted best practice not to try to 'trick' users into accidentally subscribing to things. It may be better to leave the option as 'Off' and use some other way to display a message to encourage users to subscribe.
The simplest way would be to modify the template and substitute the checkbox with a hidden input which is always set to 1. You need to edit the file /app/design/frontend/your_interface/your_theme/template/customer/form/register.phtml.
Remove this chunk of code:
<li>
<input type="checkbox" name="is_subscribed" title="<?php echo $this->__('Sign Up for Newsletter') ?>" value="1" id="is_subscribed" <?php if($this->getFormData()->getIsSubscribed()){ ?> checked="checked"<?php }elseif($this->getFormData()->getIsSubscribed == NULL){ ?> checked="checked"<?php }?> />
<label for="is_subscribed"><?php echo $this->__('Sign Up for Newsletter') ?></label>
</li>
And add your hidden input just after the other ones near the top of the form:
<input type="hidden" name="success_url" value="<?php echo $this->getSuccessUrl() ?>" />
<input type="hidden" name="error_url" value="<?php echo $this->getErrorUrl() ?>" />
<input type="hidden" name="is_subscribed" value="1" id="is_subscribed" />
Related
Guys I am stuck here in Codeigniter validation. The scenario is that I want to display all the error messages right below each respective input field and not all the error messages together on the top of the form. Could anyone help me, how to do this?
Check below mentioned code. This will help you.
<h5>Username</h5>
<?php echo form_error('username'); ?>
<input type="text" name="username" value="<?php echo set_value('username'); ?>" size="50" />
<h5>Password</h5>
<?php echo form_error('password'); ?>
<input type="text" name="password" value="<?php echo set_value('password'); ?>" size="50" />
<h5>Password Confirm</h5>
<?php echo form_error('passconf'); ?>
<input type="text" name="passconf" value="<?php echo set_value('passconf'); ?>" size="50" />
<h5>Email Address</h5>
<?php echo form_error('email'); ?>
<input type="text" name="email" value="<?php echo set_value('email'); ?>" size="50" />
Use form_error() function to do that. As describe in manual
echo form_error('username');
All you have to do is put this line under the field where you want to see error message. Here username is the name of the form field
more details
https://www.codeigniter.com/user_guide/libraries/form_validation.html#showing-errors-individually
write below code after your text or drop-down field
<?php echo form_error('field_name','<div class="errorClass">','</div>');?>
I am facing problem when installing magento on my xampp server. There is some path url issue which I have been facing. please look at the screenshot
chrome-extension://mcbpblocgmgfnpjjppndjkmgjaogfceg/fsCaptured.html
Open \app\design\install\default\default\template\install\config.phtml
Find the textbox where the base url is entered. It will be around line no 85 with name ‘config[unsecure_base_url]‘
Remove ‘validate-url’ from its class and save the file.
<li>
<label for="base_url"><?php echo $this->__('Base URL') ?> <span class="required">*</span></label><br />
<input type="text" name="config[unsecure_base_url]" id="base_url" value="<?php echo $this->getFormData()->getUnsecureBaseUrl() ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Base URL')) ?>" class="required-entry validate-url input-text" />
</li>
Replace with
<li>
<label for="base_url"><?php echo $this->__('Base URL') ?> <span class="required">*</span></label><br />
<input type="text" name="config[unsecure_base_url]" id="base_url" value="<?php echo $this->getFormData()->getUnsecureBaseUrl() ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Base URL')) ?>" class="required-entry input-text" />
</li>
4.Refresh installation page and continue.
Try check "Skip Base URL Validation Before the next step"
Take a look at Please enter a valid URL. Protocol is required (http://, https:// or ftp://) in Magento 1.9.2 installing?
I want to remove the validation of state/province from billing information process bar in one page checkout page.
I tried but unable to do that. Please check the code:
<div class="field">
<label for="billing:region_id" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
<div class="input-box">
<input type="text" title="<?php echo $this->__('state') ?>" name="billing[region]" value="<?php echo $this->escapeHtml($this->getAddress()->getRegion()) ?>" class="input-text stat<?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" id="billing:region" />
</div>
</div>
Try this:
Go to your admin panel -> System -> Configuration -> General -> States Options -> "State is required for"
and then de-select any countries for which you do not want a state to be required.
(Set "Display not required State" to "no" if you want to hide the state input entirely for countries that do not require it.)
How can you remove the QTY box from the product details page for configurable products?
Is it possible to remove the QTY box from the shopping cart too?
I am using Magento Community version 1.7
If you are using base Magento theme then,
Go to
base->default->template->catalog->product->view->addtocart.phtml
There you will find the QTY input box. Now you can do whatever you want.
Have a nice day.
The path is template reference only, you should follow magento coding
standard and modify accordingly. Don't change base files. I hope you know about Magento
Fallback hierarchy.
Go to app/design/frontend/your_interface/your_theme/template/catalog/product/view/addtocart.phtml
Find:
<input name="qty" type="text" class="input-text qty" id="qty" maxlength="12" value="<?php echo $this->getMinimalQty($_product) ?>"/>
and replace with:
<input type="hidden" disabled="disabled" name="qty" id="qty" maxlength="12" value="<?php echo $this->getMinimalQty($_product)? $this->getMinimalQty($_product): 1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
I have added extra customer fields for customer. Now I want to put those extra fields to own page like address is in My account page. How can I do that?
you will need to copy the file app/design/frontend/base/default/template/customer/form/edit.phtml to app/design/frontend/default/default/template/customer/form/edit.phtml then add an input file or else inside it.
Here an example (the code is customized, so adapt to your situation):
<label for="language" class="required"><em>*</em><?php echo Mage::helper('customer')->__('My language') ?></label>
<div class="input-box">
<input type="text" value="<?php echo $this->getCustomer()->getLanguage(); ?>" id="language" name="language" />
</div>