Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
v:2.0:snippets:dynamically_require_phone [2015/03/30 16:05] – Changing script to be more thorough sparkweb | v:2.0:snippets:dynamically_require_phone [2018/07/30 06:02] (current) – adam | ||
---|---|---|---|
Line 5: | Line 5: | ||
==== Add Javascript ==== | ==== Add Javascript ==== | ||
- | Put this javascript in the header of your checkout template. You may want to put it in the "add code to the header and footer" | + | Copy and paste the following code into your store' |
- | <code javascript>< | + | <code javascript> |
- | function requirePhone() { | + | <script type=" |
- | var country = FC.json.shipping_address.country; | + | function requirePhone(params) { |
- | var phone_required = FC.json.required_fields.indexOf(" | + | var country = params.address.country; |
- | if (country != " | + | var phone_required = FC.json.required_fields.indexOf(" |
- | FC.json.required_fields.push(' | + | if (country != " |
- | FC.json.config.template_config.custom_checkout_field_requirements[' | + | FC.json.required_fields.push(' |
- | FC.checkout.renderCustomerShipping(); | + | FC.json.config.template_config.custom_checkout_field_requirements[' |
- | jQuery("# | + | FC.Template(" |
- | } else if (country == " | + | FC.checkout.renderCustomerShipping(); |
- | FC.json.required_fields.splice(phone_required, | + | } else if (country == " |
- | FC.json.config.template_config.custom_checkout_field_requirements[' | + | FC.json.required_fields.splice(phone_required, |
- | FC.checkout.renderCustomerShipping(); | + | FC.json.config.template_config.custom_checkout_field_requirements[' |
- | jQuery("# | + | FC.util.removeError(params.address.prefix + " |
- | } | + | |
+ | FC.Template("checkout").clearOutput(); | ||
+ | FC.checkout.renderCustomerShipping(); | ||
+ | } | ||
} | } | ||
- | if (FC.json.context == " | + | |
- | FC.client.on(" | + | FC.client.on(" |
- | FC.client.on(" | + | FC.client.on(" |
- | } | + | var addresses = []; |
- | </ | + | if (FC.json.shipping_address.has_shippable_products) { |
+ | addresses = FC.json.has_multiship ? FC.json.multiship_data : [FC.json.shipping_address]; | ||
+ | } | ||
+ | if (FC.json.use_alternate_shipping_address || !FC.json.shipping_address.has_shippable_products) { | ||
+ | addresses.push(FC.json.billing_address); | ||
+ | } | ||
+ | for (var i = 0; i < addresses.length; | ||
+ | | ||
+ | } | ||
+ | }); | ||
+ | </ | ||
+ | {% endif %}</ |