Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Magento
- *
- * NOTICE OF LICENSE
- *
- * This source file is subject to the Open Software License (OSL 3.0)
- * that is bundled with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://opensource.org/licenses/osl-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.
- *
- * @category Techinflo
- * @package Techinflo_Checkavailability
- * @copyright Techinflo(www.techinflo.com)
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
- */
- /**
- * Product view template
- *
- * @see Techinflo_Checkavailability_Block_view
- * @see Techinflo_Checkavailability_Block_view
- */
- ?>
- <?php if ($this->getIsActive()): ?>
- <?php $pid = Mage::registry('current_product')->getId(); ?>
- <?php $set = $this->cookieparams(); ?>
- <div class="chkavl">
- <div class="check-avail check-avail1" id="check-avail1"><a href="javascript:void(0);"><?php
- if ((($_COOKIE["avl_pin_code"] != '') && isset($_COOKIE["avl_pin_code"])) || (($_COOKIE["pin_code"] != '') && isset($_COOKIE["pin_code"]))) {
- if ($_COOKIE["avl_pin_code"] != '' && isset($_COOKIE["avl_pin_code"]))
- echo "<span>Location:" . $_COOKIE["avl_pin_code"] . " <span class='changepin'>Change</span></span>";
- if ($_COOKIE["pin_code"] != '' && isset($_COOKIE["pin_code"]))
- echo "<span>Location:" . $_COOKIE["pin_code"] . " <span class='changepin'>Change</span></span>";
- }else {
- echo "<span>Check Avaliabilty</span>";
- }
- ?></a></div>
- <div id="check-data" >
- <input class="check-input" type="text" id="checkpin" name="checkpin" value="" />
- <div class="check-data"><button class="btn btn-gray" id="ckhbtn" type="button" onclick="chkavail();" ><span>check</span></button>
- <span id="loader" style="display:none;"><img src="<?php echo $this->getSkinUrl('css/techinflo/checkavailability/ajax-loader.gif'); ?>"></span></div>
- <div id="resp" style="display:none;"></div>
- </div>
- <div class="check-avail check-avail2" id="check-avail2" style="display:none;"><a href="javascript:void(0);">
- <span>Hide</span>
- </a></div>
- <div id="location_msg" style="display:none"></div>
- <div id="location_msg_avl" style="display:none"></div>
- </div>
- <script>
- <?php if ((isset($_COOKIE["pin_code"]) && $_COOKIE["pin_code"] != '') || (isset($_COOKIE["avl_pin_code"]) && $_COOKIE["avl_pin_code"] != "")) { ?>
- var cb = jQuery.noConflict();
- cb(document).ready(function() {
- var cb = jQuery.noConflict();
- cb("#resp").html('');
- var id = "<?php echo $pid; ?>";
- <?php if (isset($_COOKIE["pin_code"]) && $_COOKIE["pin_code"] != '') { ?>
- var pintext = "<?php echo $_COOKIE["pin_code"]; ?>";
- <?php } else { ?>
- var pintext = "<?php echo $_COOKIE["avl_pin_code"]; ?>";
- <?php } ?>
- url = "<?php echo Mage::getUrl('checkavl/index/detail') ?>" + 'id/' + id + '/pincode/' + pintext;
- cb("#loader").show();
- cb("#ckhbtn").hide();
- cb.ajax({url: url, success: function(result) {
- var resp_result = cb.trim(result);
- var html = "";
- res = resp_result.split(",");
- if (res[0] == '1') {
- setCookie("avl_pin_code", '', 1);
- cb("#loader").hide();
- cb("#ckhbtn").show();
- cb(".add-to-qty").hide();
- //cb(".addwhis").hide();
- html = '<button class="button btn-cart" title="Add to Cart" type="button"><span>Add to Cart</span></button>';
- cb(".addbut").html(html);
- cb("#location_msg").show();
- cb("#location_msg_avl").hide();
- cb("#location_msg").text('<?php echo $this->failureMsg(); ?>');
- setCookie("pin_code", res[1], 1);
- cb("#check-avail1 a").html('<span class="lbl">Location:</span><span class="pinonly">' + res[1] + '</span> <span class="changepin">Change</span>');
- cb("#checkpin").val(cb.trim(res[1]));
- var response = "<span class='resp' style='color:red'><?php echo $this->failureMsg(); ?></span>";
- } else {
- cb("#check-avail1 a").html('<span class="lbl">Location:</span><span class="pinonly">' + result + '</span> <span class="changepin">Change</span>');
- cb("#loader").hide();
- cb("#ckhbtn").show();
- cb(".add-to-qty").show();
- setCookie("pin_code", '', 1);
- setCookie("avl_pin_code", result, 1);
- html = '<button onclick="productAddToCartForm.submit(this)" class="button btn-cart" title="Add to Cart" type="button"><span>Add to Cart</span></button>';
- cb(".addbut").html(html);
- cb("#location_msg").hide();
- cb("#checkpin").val(cb.trim(result));
- cb("#location_msg_avl").show();
- cb("#location_msg_avl").text('<?php echo $this->successMsg() ?>');
- var response = "<span class='resp' style='color:green'><?php echo $this->successMsg() ?>: " + result + "</span>";
- }
- cb("#resp").html(response);
- cb("#resp").show();
- }});
- return false;
- });
- <?php } ?>
- function chkavail() {
- var cb = jQuery.noConflict();
- cb("#resp").html('');
- var id = "<?php echo $pid; ?>";
- var pintext = cb("#checkpin").val();
- url = "<?php echo Mage::getUrl('checkavl/index/detail') ?>" + 'id/' + id + '/pincode/' + pintext;
- cb("#loader").show();
- cb("#ckhbtn").hide();
- cb.ajax({url: url, success: function(result) {
- var resp_result = cb.trim(result);
- var html = "";
- res = resp_result.split(",");
- if (res[0] == '1' && res[1] != '') {
- setCookie("avl_pin_code", '', 1);
- cb("#loader").hide();
- cb("#ckhbtn").show();
- cb(".add-to-qty").hide();
- html = '<button class="button btn-cart" title="Add to Cart" type="button"><span>Add to Cart</span></button>';
- cb(".addbut").html(html);
- cb("#location_msg").show();
- cb("#location_msg_avl").hide();
- cb("#location_msg").text('<?php echo $this->failureMsg(); ?>');
- setCookie("pin_code", res[1], 1);
- cb("#check-avail1 a").html('<span class="lbl">Location:</span><span class="pinonly">' + res[1] + '</span> <span class="changepin">Change</span>');
- var response = "<span class='resp' style='color:red'><?php echo $this->failureMsg(); ?></span>";
- } else {
- cb("#check-avail1 a").html('<span class="lbl">Location:</span><span class="pinonly">' + result + '</span> <span class="changepin">Change</span>');
- cb("#loader").hide();
- cb("#ckhbtn").show();
- cb(".add-to-qty").show();
- setCookie("pin_code", '', 1);
- setCookie("avl_pin_code", result, 1);
- html = '<button onclick="productAddToCartForm.submit(this)" class="button btn-cart" title="Add to Cart" type="button"><span>Add to Cart</span></button>';
- cb(".addbut").html(html);
- cb("#location_msg").hide();
- if (cb("#checkpin").val() == "") {
- setCookie("pin_code", '', 1);
- setCookie("avl_pin_code", '', 1);
- cb("#check-avail1 a").html('<span>Check Avaliabilty</span>');
- var response = "";
- cb("#location_msg_avl").hide();
- } else {
- cb("#checkpin").val(cb.trim(result));
- cb("#location_msg_avl").show();
- cb("#location_msg_avl").text('<?php echo $this->successMsg() ?>');
- var response = "<span class='resp' style='color:green'><?php echo $this->successMsg() ?>: " + result + "</span>";
- }
- }
- cb("#resp").html(response);
- cb("#resp").show();
- }});
- return false;
- }
- function setCookie(c_name, value, exdays)
- {
- var exdate = new Date();
- exdate.setDate(exdate.getDate() + exdays);
- var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
- document.cookie = c_name + "=" + c_value + ";path=/";
- }
- </script>
- <script>
- var $p = jQuery.noConflict();
- $p('#check-avail1').click(function() {
- $p(".check-data").show();
- $p("#checkpin").show();
- $p(this).hide();
- $p('#check-avail2').show();
- $p('#check-data').show();
- });
- $p('#check-avail2').click(function() {
- $p(this).hide();
- $p('#check-avail1').show();
- $p('#check-data').hide();
- });
- </script>
- <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement