Skip to main content

Buy Now Adding in Product Page

<?xml version="1.0" encoding="UTF-8"?>
<modification>
<name>Buy Now Product</name>
<id>Buy Now Product</id>
<code>OCMP_BNP</code>
<version>3.0.2</version>
<vqmver required="true">2.4.0</vqmver>
<author>ManiNalliapppan</author>
 
  <file path="catalog/language/en-gb/product/product.php">

<operation>
            <search ><![CDATA[ $_['text_year']                = 'year'; ]]></search>
            <add position="after"><![CDATA[$_['text_buynow']                = 'Buy Now';]]></add>
        </operation>
  </file>

   <file path="catalog/view/theme/default/template/product/product.twig">

<operation>
            <search ><![CDATA[ <button type="button" id="button-cart" data-loading-text="{{ text_loading }}" class="btn btn-primary btn-lg btn-block">{{ button_cart }}</button> ]]></search>
            <add position="after"><![CDATA[<button type="button" id="button-buy" data-loading-text="{{ text_loading }}" class="btn btn-primary btn-lg btn-block" title="Buy Now">{{text_buynow}} </button>]]></add>
        </operation>


<operation>
            <search ><![CDATA[ {{ footer }} ]]></search>
            <add position="after"><![CDATA[<script type="text/javascript"><!--
$('#button-buy').on('click', function() {
$.ajax({
url: 'index.php?route=checkout/cart/add',
type: 'post',
data: $('#product input[type=\'text\'], #product input[type=\'hidden\'], #product input[type=\'radio\']:checked, #product input[type=\'checkbox\']:checked, #product select, #product textarea'),
dataType: 'json',
beforeSend: function() {
$('#button-cart').button('loading');
},
complete: function() {
$('#button-cart').button('reset');
},
success: function(json) {
$('.alert-dismissible, .text-danger').remove();
$('.form-group').removeClass('has-error');

if (json['error']) {
if (json['error']['option']) {
for (i in json['error']['option']) {
var element = $('#input-option' + i.replace('_', '-'));

if (element.parent().hasClass('input-group')) {
element.parent().after('<div class="text-danger">' + json['error']['option'][i] + '</div>');
} else {
element.after('<div class="text-danger">' + json['error']['option'][i] + '</div>');
}
}
}

if (json['error']['recurring']) {
$('select[name=\'recurring_id\']').after('<div class="text-danger">' + json['error']['recurring'] + '</div>');
}

// Highlight any found errors
$('.text-danger').parent().addClass('has-error');
}

if (json['success']) {
     window.location.href = 'index.php?route=checkout/checkout';
$('.breadcrumb').after('<div class="alert alert-success alert-dismissible">' + json['success'] + '<button type="button" class="close" data-dismiss="alert">&times;</button></div>');

$('#cart > button').html('<span id="cart-total"><i class="fa fa-shopping-cart"></i> ' + json['total'] + '</span>');

$('html, body').animate({ scrollTop: 0 }, 'slow');

$('#cart > ul').load('index.php?route=common/cart/info ul li');
}
},
        error: function(xhr, ajaxOptions, thrownError) {
            alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
        }
});
});
//--></script>
]]></add>
        </operation>




</file>
 

</modification>

Comments

Popular posts from this blog

About The Author

Hi All, Welcome to the Opencart Tutorial I have 4.5 Year industry experience in E-commerce and Business website Development. I have created more then 50 Websites.  I am expert in the opencart, wordpress , magento, PHP, HTML5, CSS. I will write this tutorial on opencart website from Installation to module customization

Opencart Folder Struture And Admin URL Rename

Opencart Folder Struture The Opencart Contain Following folder: 1. Admin 2.Catalog 3.Image 4. System Following Files: 1.index.php 2.config.php 3. .htaccess.txt 4. instructions.txt 5.  license.txt How to rename admin URL in opencart: For Example : http://example.com/admin/  to  http://example.com/ExampleAdmin/ 1. We need to rename admin to ExampleAdmin. 2.  We need to change following  line in  config.php file define('HTTP_SERVER', 'http://example.com/admin/'); define('HTTPS_SERVER', 'https://example.com/admin/'); define('DIR_APPLICATION', 'C:/xampp/htdocs/bunjeeopencart/admin/'); define('DIR_LANGUAGE', 'C:/xampp/htdocs/bunjeeopencart/admin/language/'); define('DIR_TEMPLATE', 'C:/xampp/htdocs/bunjeeopencart/admin/view/template/'); Changed To define('HTTP_SERVER', 'http://example.com/ExampleAdmin/'); define('HTTPS_SERVER', 'https://...

Filter By Brand in opencart

<?xml version="1.0" encoding="UTF-8"?> <modification> <name>Brand By Filter</name> <id>Brand By Filter</id> <code>OCMP_BBF</code> <version>3.0.2</version> <vqmver required="true">2.4.0</vqmver> <author>ManiNalliapppan</author> <file path="catalog/controller/product/category.php"> <operation>             <search><![CDATA[$results = $this->model_catalog_category->getCategories($category_id);]]></search>             <add position="after"><![CDATA[// get manufacturers for child categories $categoryids_with_childs = array(); $categoryids_with_childs = $this->model_catalog_category->getCategoriesByParentId($category_id); array_push($categoryids_with_childs, $category_id); $manufacturers = $this->model_catalog_manufacturer->getManufacturersByCategories(...