Number of countries for billing and Shipping to be different in Magento - magento

I want to display some countries in shipping address and some other countries in the billing address.
I have followed the suggestion provided here .But after doing that my state/province input box doesn't appear.
Like this ->

look at line 78 ish in (path_to_magento)\app\design\frontend\default(my_skin_name)\template\checkout\onepage\shipping.phtml
and it should be like this. Maybe you deleted something -
<div class="field">
<label for="shipping:region" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
<div class="input-box">
<select id="shipping:region_id" name="shipping[region_id]" title="<?php echo $this->__('State/Province') ?>" class="validate-select" style="display:none;">
<option value=""><?php echo $this->__('Please select region, state or province') ?></option>
</select>
<script type="text/javascript">
//<![CDATA[
$('shipping:region_id').setAttribute('defaultValue', "<?php echo $this->getAddress()->getRegionId() ?>");
//]]>
</script>
<input type="text" id="shipping:region" name="shipping[region]" value="<?php echo $this->htmlEscape($this->getAddress()->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text" style="display:none;" />
</div>
</div>

Related

Custom contact form gives me 404 error

I've created a custom contact form for each magento product, I've set up all the files and inserted this code inside a Magento static block:
{{block type="core/template" form_action="/PersonalizzazioniEmail/index/post/" template="catalog/product/view/form-personalizzazione.phtml"}}
Here's the form-personalizzazione.phtml
<?php $productId=$this->getRequest()->getParams();
$model = Mage::getModel('catalog/product');
$_product = $model->load($productId["id"]);
?>
<div id="messages_product_view"><?php echo $this->getMessagesBlock()->toHtml() ?></div>
<div class="page-title">
<h1><?php echo Mage::helper('contacts')->__('Contact Us') ?></h1>
</div>
<form action="<?php echo $this->getFormAction(); ?>" id="contactForm" method="post">
<input type="hidden" id="product" name="product" value="<?php echo $_product->getName() ?>" />
<div class="fieldset">
<h2 class="legend"><?php echo Mage::helper('contacts')->__('Contact Information') ?></h2>
<ul class="form-list">
<li class="fields">
<div class="field">
<label for="name" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Name') ?></label>
<div class="input-box">
<input name="name" id="name" title="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('contacts')->__('Name')) ?>" value="<?php echo $this->escapeHtml($this->helper('contacts')->getUserName()) ?>" class="input-text required-entry" type="text" />
</div>
</div>
<div class="field">
<label for="email" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Email') ?></label>
<div class="input-box">
<input name="email" id="email" title="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('contacts')->__('Email')) ?>" value="<?php echo $this->escapeHtml($this->helper('contacts')->getUserEmail()) ?>" class="input-text required-entry validate-email" type="text" />
</div>
</div>
</li>
<li>
<label for="telephone"><?php echo Mage::helper('contacts')->__('Telephone') ?></label>
<div class="input-box">
<input name="telephone" id="telephone" title="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('contacts')->__('Telephone')) ?>" value="" class="input-text" type="text" />
</div>
</li>
<li class="wide">
<label for="comment" class="required"><em>*</em><?php echo Mage::helper('contacts')->__('Comment') ?></label>
<div class="input-box">
<textarea name="comment" id="comment" title="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('contacts')->__('Comment')) ?>" class="required-entry input-text" cols="5" rows="3"></textarea>
</div>
</li>
</ul>
</div>
<div class="fieldset privacy">
<ul class="form-list">
<?php if (Mage::helper('privacy')->isPrivacyEnabled()): ?>
<li>
<?php echo $this->getChildHtml('privacy.include.contacts'); ?>
</li>
<?php endif;?>
</ul>
</div>
<div class="buttons-set">
<p class="required"><?php echo Mage::helper('contacts')->__('* Required Fields') ?></p>
<input type="text" name="hideit" id="hideit" value="" style="display:none !important;" />
<button type="submit" title="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('contacts')->__('Submit')) ?>" class="button"><span><span><?php echo Mage::helper('contacts')->__('Submit') ?></span></span></button>
</div>
</form>
<script type="text/javascript">
//<![CDATA[
var contactForm = new VarienForm('contactForm', true);
//]]>
</script>
But I get a 404 error when I submit the form, what could be the reason?
Thanks
Create a Custom Contact Form in Magento,Kindly visit below URLs.
http://inchoo.net/magento/magento-email/magento-custom-email-contact-form-with-notification-system/
http://ignaciogondra.com/2015/08/24/how-to-create-a-custom-contact-form-in-magento/
If you don't want to use custom code,You can use this paid extension.
https://www.magentocommerce.com/magento-connect/custom-contact-forms.html
You can also use this Product Question,It's might be fulfilled your requirement. This is free extension.
https://www.magentocommerce.com/magento-connect/product-question-1.html
Hope It's helpful for you.

how can i get us all state in magento?

<li class="state">
<label for="State" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
<div class="input-box">
<select id="State" name="State" title="<?php echo $this->__('State') ?>" class="validate-select" style="display:none;">
<option value=""><?php echo $this->__('Please select region, state or province') ?></option>
</select>
<input type="text" id="State" name="State" value="<?php echo $this->escapeHtml($this->getAddress()->getRegion()) ?>" title="<?php echo $this->__('State') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" style="display:none;" />
</div>
</li>
You can use get the list of states as:
Code
<li class="state">
<label for="State" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
<div class="input-box">
<select id="State" name="State" title="<?php echo $this->__('State') ?>" class="validate-select" style="display:none;">
<option value=""><?php echo $this->__('Please select region, state or province') ?></option>
<?php
$regionCollection = Mage::getModel('directory/region')->getResourceCollection()
//->addCountryFilter()
->load();
foreach($regionCollection as $region){
echo "<option value=$region[name]>".$region['name'] . "</option>";
}
?>
</select>
<input type="text" id="State" name="State" value="<?php echo $this->escapeHtml($this->getAddress()->getRegion()) ?>" title="<?php echo $this->__('State') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" style="display:none;" />
</div>
</li>
Note: this code comment: //->addCountryFilter() can be uncommented if you want to filter by specific country e.g 'US' or 'CA' or 'FR' etc
Use directory API instead of resource collection:
Mage::getModel('directory/region_api')->items('US')

how to add multiple newsletter in one page with magento?

I want to add two newsletter in my site.One is in the footer and another one when i hover the topmenu.
I tried to add two newsletter in my page and it also worked but the problem is if i am adding another newsletter in my site then first newsletter is not working.I donot know what is the problem.
If anyone knows this, please help me out.
Thanks!
I put subscribe_footer.phtml in \app\design\frontend\default\mytheme\template\newsletter
<div class="row-7-col-1">
<h2><?php echo $this->__('newsletter') ?></h2>
<p><?php echo $this->__('Sign up to our newsletter and get exclusive deals you wont find anywhere else straight to your inbox!') ?></p>
<form action="<?php echo $this->getFormActionUrl() ?>" method="post" id="newsletter-footer-validate-detail-footer">
<input type="text" name="email" id="newsletter-footer" title="<?php echo $this->__('Sign up for our newsletter') ?>" class="input-text required-entry validate-email" />
<input type="submit" title="<?php echo $this->__('Submit') ?>" class="newsbtn" value="submit">
</form></div>
<script type="text/javascript">
//<![CDATA[
var newsletterSubscriberFormDetail = new VarienForm('newsletter-footer-validate-detail-footer');
//]]>
</script>
</div>
For another newsletter,I put subscribe.phtml in \app\design\frontend\default\mytheme\template\newsletter
<div class="row-7-col-1">
<h2><?php echo $this->__('newsletter') ?></h2>
<p><?php echo $this->__('Sign up to our newsletter and get exclusive deals you wont find anywhere else straight to your inbox!') ?></p>
<form action="<?php echo $this->getFormActionUrl() ?>" method="post" id="newsletter-validate-detail">
<input type="text" name="email" id="newsletter" class="field required-entry validate-email"/>
<input type="submit" title="<?php echo $this->__('Submit') ?>" class="newsbtn" value="submit">
</form></div>
<script type="text/javascript">
//<![CDATA[
var newsletterSubscriberFormDetail = new VarienForm('newsletter-validate-detail');
//]]>
</script>
</div>
please check and tell me why only one newsletter validation is working
<div class="block block-subscribe">
<form action="<?php echo $this->getFormActionUrl() ?>" method="post" id="newsletter-validate-detail_footer">
<input type="text" name="email" placeholder="Enter email" id="email_footer" class="input-text required-entry validate-email mytxt2" />
<button type="submit" title="<?php echo $this->__('Subscribe') ?>" class="button"><span><span><?php echo $this->__('Subscribe') ?></span></span></button>
</form>
<script type="text/javascript">
//<![CDATA[
var newsletterSubscriberFormDetail_footer = new VarienForm('newsletter-validate-detail_footer');
//]]>
</script>
Two Newsletters are working as well as validation also worked for me.
Copy the newsletter/subscribe file and rename to newsletter/subscribe2.
Then just rename the validation name on newsletter.

How to edit "design/frontend/base/default/ template/customer/address/edit.phtml" in magento?

<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license#magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* #category design
* #package base_default
* #copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
* #license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
?>
<?php
/**
* Edit customer address template
*
* #see Mage_Customer_Block_Address_Edit
*/
?>
<?php if($this->getTitle()): ?>
<div class="page-title">
<h1><?php echo $this->getTitle() ?></h1>
</div>
<?php endif; ?>
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
<form action="<?php echo $this->getSaveUrl() ?>" method="post" id="form-validate">
<div class="fieldset">
<?php echo $this->getBlockHtml('formkey')?>
<input type="hidden" name="success_url" value="<?php echo $this->getSuccessUrl() ?>" />
<input type="hidden" name="error_url" value="<?php echo $this->getErrorUrl() ?>" />
<h2 class="legend"><?php echo $this->__('Contact Information') ?></h2>
<ul class="form-list">
<li class="fields">
<?php echo $this->getNameBlockHtml() ?>
</li>
<li class="wide">
<label for="company"><?php echo $this->__('Company') ?></label>
<div class="input-box">
<input type="text" name="company" id="company" title="<?php echo $this->__('Company') ?>" value="<?php echo $this->escapeHtml($this->getAddress()->getCompany()) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('company') ?>" />
</div>
</li>
<li class="fields">
<div class="field">
<label for="telephone" class="required"><em>*</em><?php echo $this->__('Telephone') ?></label>
<div class="input-box">
<input type="text" name="telephone" value="<?php echo $this->escapeHtml($this->getAddress()->getTelephone()) ?>" title="<?php echo $this->__('Telephone') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('telephone') ?>" id="telephone" />
</div>
</div>
<div class="field">
<label for="fax"><?php echo $this->__('Fax') ?></label>
<div class="input-box">
<input type="text" name="fax" id="fax" title="<?php echo $this->__('Fax') ?>" value="<?php echo $this->escapeHtml($this->getAddress()->getFax()) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('fax') ?>" />
</div>
</div>
</li>
</ul>
</div>
<div class="fieldset">
<h2 class="legend"><?php echo $this->__('Address') ?></h2>
<ul class="form-list">
<?php $_streetValidationClass = $this->helper('customer/address')->getAttributeValidationClass('street'); ?>
<li class="wide">
<label for="street_1" class="required"><em>*</em><?php echo $this->__('Street Address') ?></label>
<div class="input-box">
<input type="text" name="street[]" value="<?php echo $this->escapeHtml($this->getAddress()->getStreet(1)) ?>" title="<?php echo $this->__('Street Address') ?>" id="street_1" class="input-text <?php echo $_streetValidationClass ?>" />
</div>
</li>
<?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
<?php for ($_i = 2, $_n = $this->helper('customer/address')->getStreetLines(); $_i <= $_n; $_i++): ?>
<li class="wide">
<div class="input-box">
<input type="text" name="street[]" value="<?php echo $this->escapeHtml($this->getAddress()->getStreet($_i)) ?>" title="<?php echo $this->__('Street Address %s', $_i) ?>" id="street_<?php echo $_i ?>" class="input-text <?php echo $_streetValidationClass ?>" />
</div>
</li>
<?php endfor; ?>
<?php if ($this->helper('customer/address')->isVatAttributeVisible()) : ?>
<li class="wide">
<label for="vat_id"><?php echo $this->__('VAT Number') ?></label>
<div class="input-box">
<input type="text" name="vat_id" value="<?php echo $this->escapeHtml($this->getAddress()->getVatId()) ?>" title="<?php echo $this->__('VAT Number') ?>" id="vat_id" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('vat_id') ?>" />
</div>
</li>
<?php endif; ?>
<li class="fields">
<div class="field">
<label for="city" class="required"><em>*</em><?php echo $this->__('City') ?></label>
<div class="input-box">
<input type="text" name="city" value="<?php echo $this->escapeHtml($this->getAddress()->getCity()) ?>" title="<?php echo $this->__('City') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>" id="city" />
</div>
</div>
<div class="field">
<label for="region_id" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
<div class="input-box">
<select id="region_id" name="region_id" title="<?php echo $this->__('State/Province') ?>" class="validate-select" style="display:none;">
<option value=""><?php echo $this->__('Please select region, state or province') ?></option>
</select>
<script type="text/javascript">
//<![CDATA[
$('region_id').setAttribute('defaultValue', "<?php echo $this->getAddress()->getRegionId() ?>");
//]]>
</script>
<input type="text" id="region" name="region" value="<?php echo $this->escapeHtml($this->getAddress()->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" />
</div>
</div>
</li>
<li class="fields">
<div class="field">
<label for="zip" class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
<div class="input-box">
<input type="text" name="postcode" value="<?php echo $this->escapeHtml($this->getAddress()->getPostcode()) ?>" title="<?php echo $this->__('Zip/Postal Code') ?>" id="zip" class="input-text validate-zip-international <?php echo $this->helper('customer/address')->getAttributeValidationClass('postcode') ?>" />
</div>
</div>
<div class="field">
<label for="country" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
<div class="input-box">
<?php echo $this->getCountryHtmlSelect() ?>
</div>
</div>
</li>
<li<?php if($this->canSetAsDefaultBilling()) echo ' class="control"' ?>>
<?php if($this->isDefaultBilling()): ?>
<strong><?php echo $this->__('Default Billing Address') ?></strong>
<?php elseif($this->canSetAsDefaultBilling()): ?>
<input type="checkbox" id="primary_billing" name="default_billing" value="1" title="<?php echo $this->__('Use as My Default Billing Address') ?>" class="checkbox" /><label for="primary_billing"><?php echo $this->__('Use as my default billing address') ?></label>
<?php else: ?>
<input type="hidden" name="default_billing" value="1" />
<?php endif; ?>
</li>
<li<?php if($this->canSetAsDefaultShipping()) echo ' class="control"' ?>>
<?php if($this->isDefaultShipping()): ?>
<strong><?php echo $this->__('Default Shipping Address') ?></strong>
<?php elseif($this->canSetAsDefaultShipping()): ?>
<input type="checkbox" id="primary_shipping" name="default_shipping" value="1" title="<?php echo $this->__('Use as My Default Shipping Address') ?>" class="checkbox" /><label for="primary_shipping"><?php echo $this->__('Use as my default shipping address') ?></label>
<?php else: ?>
<input type="hidden" name="default_shipping" value="1" />
<?php endif; ?>
</li>
</ul>
</div>
<div class="buttons-set">
<p class="required"><?php echo $this->__('* Required Fields') ?></p>
<p class="back-link"><small>« </small><?php echo $this->__('Back') ?></p>
<button type="submit" title="<?php echo $this->__('Save Address') ?>" class="button"><span><span><?php echo $this->__('Save Address') ?></span></span></button>
</div>
</form>
<script type="text/javascript">
//<![CDATA[
var dataForm = new VarienForm('form-validate', true);
new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'zip');
//]]>
</script>``
i want to when i click on button then it create pop up box with ok button and when i am click on ok button the default procedure of magento will be continue.
and all that by using different model in local code pool.
it is possible??
You could use something like that http://www.miniscript.it/demopages/confirmjquerydialog/demo.php and manage this action with jquery.
Easy, just add hidden block to the template, change default confirmation button to fake button and enable action:
<button onclick="document.getElementById('hiddendivid').style.display = 'block'; return false;">
Fake button opens div with true button
</button>
<div id="hiddendivid" style="display: none;">
this is popup div
<input type="submit" name="truemagentosubmit" value="This will real submit the form" />
<input type="submit" value="Or close thos window" onclick="document.getElementById('hiddendivid').style.display = 'none'; return false;" />
</div>
all will work in the same form like a standard submit.

Get all usa state in state drop down listin in magento registration

I hope you all are doing well,
I am working in magento 1.6.0.1.
My current site is just for USA, so in registration page don't need country drop down list,and must display all USA state in state drop down list.
For now I set country value "US" in hidden field.
So how can I get all USA state in state drop down list
Add this in register.phtml to display all states of US:
<div class="field">
<label for="region_id" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
<div class="input-box">
<select id="region_id" name="region_id" title="<?php echo $this->__('State/Province') ?>" class="validate-select">
<option value=""><?php echo $this->__('Please select region, state or province') ?></option>
<?php
$this->setData('country_id','US'); // or 'FR'..., default is 'US'
$regions = $this->getRegionCollection();
foreach($regions as $region)
{
echo "<option value=$region[name]>".$region['name'] . "</option>";
}
?>
</select>
<script type="text/javascript">
//<![CDATA[
$('region_id').setAttribute('defaultValue', "<?php echo $this->getFormData()->getRegionId() ?>");
//]]>
</script>
<input type="text" id="region" name="region" value="<?php echo $this->escapeHtml($this->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" style="display:none;" />
</div>
</div>
</li>
<li class="fields">
<div class="field">
<label for="country" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
<div class="input-box">
<?php echo $this->getCountryHtmlSelect() ?>
</div>
</div>
and replace bottom javascript with:
<script type="text/javascript">
var dataForm = new VarienForm('form-validate', true);
new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>);
</script>
Hope it will help
from Country and States in Magento :
<script type="text/javascript">
var dataForm = new VarienForm('form-validate', true);
new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>);
</script>
This is worked for me.
<div class="field">
<label for="region_id" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
<div class="input-box">
<select id="region_id" name="region_id" title="<?php echo $this->__('State/Province') ?>" class="validate-select">
<option value=""><?php echo $this->__('Please select region, state or province') ?></option>
<?php
$regions = Mage::getModel('directory/country')->load('US')->getRegions();
foreach($regions as $region)
{
echo "<option value=$region[name]>".$region['name'] . "</option>";
}
?>
</select>
</div>
</div>

Resources