i am trying to build a extension where i want to get sku value of product on cart page, checkout page and product page. I have set the fields at backend where admin can set the company id which will be pass in button URL. how can i get the sku value on cart page. I tried many different methods but it dosent work. i am also trying to get it on product & checkout page. is there anyone who can help me out.
<?xml version="1.0" encoding="UTF-8"?>
<modification>
<name>Fast Checkout</name>
<version>1.0</version>
<link>https://google.com</link>
<author>Jamil Baig</author>
<code>fast_checkout</code>
<file path="catalog/view/theme/*/template/common/cart.twig">
<operation>
<search><![CDATA[<a href="{{ cart }}"><strong><i class="fa fa-shopping-cart"></i>]]></search>
<add position="replace"><![CDATA[<script type="text/javascript">
function clearCart() {
$.ajax({
url: 'https://adup.iot',
dataType: 'json',
success: function(json) {
$('#cart-total').html(json['total']);
if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') {
location = 'https://adup.io';
} else {
$('#cart > ul').load('https://adup.io ul li');
}
}
});
}
</script>
<a style="cursor:pointer;"><strong><i class="fa fa-times"></i> {{button_fastcheckout }}</strong></a> <a href="{{ cart }}"><strong><i class="fa fa-shopping-cart"></i>]]></add>
</operation>
</file>
<file path="catalog/controller/checkout/cart.php">
<operation>
<search><![CDATA[public function add() {]]></search>
<add position="before"><![CDATA[public function clearcart() {
$this->load->language('checkout/cart');
$json = array();
$this->cart->clear();
$total = 0;
unset($this->session->data['vouchers']);
unset($this->session->data['shipping_method']);
unset($this->session->data['shipping_methods']);
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
unset($this->session->data['reward']);
$json['total'] = sprintf($this->language->get('text_items'), $this->cart->countProducts() + (isset($this->session->data['vouchers']) ? count($this->session->data['vouchers']) : 0), $this->currency->format($total, $this->config->get('config_currency')));
if (isset($this->request->get['shoppingcart']) && $this->request->get['shoppingcart']=='true') {
$this->response->redirect($this->url->link('checkout/cart'));
} else {
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
}]]></add>
</operation>
</file>
<file path="catalog/controller/common/cart.php">
<operation>
<search><![CDATA[$this->load->language('common/cart');]]></search>
<add position="after"><![CDATA[$data['button_fastcheckout'] = $this->language->get('button_fastcheckout');]]></add>
</operation>
</file>
<file path="catalog/controller/checkout/cart.php">
<operation>
<search><![CDATA[$this->load->language('checkout/cart');]]></search>
<add position="after"><![CDATA[$this->load->controller("admin/controller/extension/module/fastcheckout");
$this->load->model('catalog/product');
$data['button_fastcheckout'] = $this->language->get('Fast Checkout');
$products = $this->cart->getProducts();
foreach ($products as $product) {
$data['product_id'] = $product['product_id'];
}
$data['link_button'] = 'https://adup.io/?companyid='.$this->config->get('module_fastcheckout_company_id').'&sku='.$data['product_id'].'&p_id='.$data['product_id'];]]></add>
</operation>
</file>
<file path="catalog/language/en-gb/common/cart.php">
<operation>
<search><![CDATA[$_['text_recurring'] = 'Payment Profile';]]></search>
<add position="before"><![CDATA[$_['button_fastcheckout'] = 'Clear Cart';]]></add>
</operation>
</file>
<file path="catalog/language/en-gb/checkout/cart.php">
<operation>
<search><![CDATA[$_['column_total']= 'Total';]]></search>
<add position="before"><![CDATA[$_['button_fastcheckout'] = 'Clear Cart';]]></add>
</operation>
</file>
<file path="catalog/view/theme/*/template/checkout/cart.twig">
<operation>
<search><![CDATA[{% if modules %}]]></search>
<add position="before"><![CDATA[{{button_fastcheckout}}]]></add>
</operation>
</file>
</modification>
solved
after getting product id, i can get sku of product on cart page
Related
I have some code for auto meta tag title, but I need to make it work for description and keywords, it's annoying to input the title every time on meta
this code will copying the product title to meta title, how i can apply to the description and keyword
<file path="admin/view/template/catalog/product_form.twig">
<operation>
<search><![CDATA[{% if error_meta_title[language.language_id] %}]]></search>
<add position="before"><![CDATA[
<script type="text/javascript">
$(function() {
$("input[name='product_description[{{ language.language_id }}][name]']").keyup(function() {
$("input[name='product_description[{{ language.language_id }}][meta_title]']").val($(this).val());
});
});
</script>
]]></add>
</operation>
</file>
Try this. This should fill description and keywords fields.
<file path="admin/view/template/catalog/product_form.twig">
<operation>
<search><![CDATA[{% if error_meta_title[language.language_id] %}]]></search>
<add position="before"><![CDATA[
<script type="text/javascript">
$(function() {
$("input[name='product_description[{{ language.language_id }}][name]']").keyup(function() {
$("input[name='product_description[{{ language.language_id }}][meta_title]']").val($(this).val());
$("#input-meta-keyword{{ language.language_id }}").val($(this).val());
$("#input-meta-description{{ language.language_id }}").val($(this).val());
});
});
</script>
]]></add>
</operation>
</file>
I am new in opencart and I am trying to make some changes using vqmod.I have built a xml file which will add some text on product_list.tpl depending on user's id.The problem is that I cannot get id.I tried a lot but still no success.If anyone knows how can I achieve this please post.I get this notice on browser -> Notice: Undefined property: Loader
Here is my xml file:
<modification>
<id>GeoDim - add message products depending on user login</id>
<version>1.0</version>
<vqmver>2.4.1</vqmver>
<author>GeoDim</author>
<file path="admin/view/template/catalog/product_list.tpl">
<operation>
<search position="after"><![CDATA[div class="pull-right"]]></search>
<add><![CDATA[
<?php
// GeoDim - add message products depending on user login
$this->load->model('user/user');
$user_group_id = $this->model_user_user->getUsersGroupId($this->user->getId());
if ($user_group_id == 1) {
echo '<p style="background-color: yellow;font-size: 21px;float: left;margin-right: 5px"><i class="fa fa-exclamation-triangle"></i>Είστε στο TEST</p>';
}else {
echo '<p style="background-color: orange;font-size: 21px;float:left;margin-right:5px"><i class="fa fa-exclamation-triangle"></i>Είστε στο LIVE</p>';
}
// END GeoDim - add message products depending on user login
?>
]]></add>
</operation>
</file>
</modification>
Which version of Opencart?
Since there's no getUsersGroupId function in model/user/user.php on opencart 2.x I used getUser here, I've tested this on opencart 2.1.0.1.
You must first get user_group_id in controller file and then send it to view file via $data, so edit this file:
admin/controller/catalog/product.php
Find getList function and add this inside it:
$this->load->model('user/user');
$user_group_id = $this->model_user_user->getUser($this->user->getId());
if ($user_group_id['user_group_id'] == 1) {
$data['paragraph'] = '<p style="background-color: yellow;font-size: 21px;float: left;margin-right: 5px"><i class="fa fa-exclamation-triangle"></i>Είστε στο TEST</p>';
}else {
$data['paragraph'] = '<p style="background-color: orange;font-size: 21px;float:left;margin-right:5px"><i class="fa fa-exclamation-triangle"></i>Είστε στο LIVE</p>';
}
and then in admin/view/template/catalog/product_list.tpl use it:
<?php echo $paragraph; ?>
Here is full code:
<modification>
<id>GeoDim - add message products depending on user login</id>
<version>1.0</version>
<vqmver>2.4.1</vqmver>
<author>GeoDim</author>
<file path="admin/controller/catalog/product.php">
<operation>
<search position="after"><![CDATA[$results = $this->model_catalog_product->getProducts($filter_data);]]></search>
<add><![CDATA[
// GeoDim - add message products depending on user login
$this->load->model('user/user');
$user_group_id = $this->model_user_user->getUser($this->user->getId());
if ($user_group_id['user_group_id'] == 1) {
$data['paragraph'] = '<p style="background-color: yellow;font-size: 21px;float: left;margin-right: 5px"><i class="fa fa-exclamation-triangle"></i>Είστε στο TEST</p>';
}else {
$data['paragraph'] = '<p style="background-color: orange;font-size: 21px;float:left;margin-right:5px"><i class="fa fa-exclamation-triangle"></i>Είστε στο LIVE</p>';
}
// END GeoDim - add message products depending on user login
]]></add>
</operation>
</file>
<file path="admin/view/template/catalog/product_list.tpl">
<operation>
<search position="after"><![CDATA[div class="pull-right"]]></search>
<add><![CDATA[
<?php echo $paragraph; ?>
]]></add>
</operation>
</file>
</modification>
just getting used to using VQMod.
What is wrong here? It isn't updating on the front-end.
<?xml version="1.0" encoding="UTF-8"?>
<modification>
<id>VQMOD CORE FOR OPENCART - DO NOT REMOVE</id>
<version>1.4.x and above</version>
<vqmver required="true">2.5.0</vqmver>
<author>vqmod.com</author>
<file name="admin/view/template/common/footer.tpl">
<operation info="Example of the vQmod">
<search position="replace"><![CDATA[
<?php echo $affiliate; ?>
]]></search>
<add><![CDATA[
I am replaced content!!
]]></add>
</operation>
</file>
</modification>
Cheers!
Actually you are trying to change the "backend" but with no luck!
I think you should read:
vQmod: https://github.com/vqmod/vqmod/wiki
Examples: https://github.com/vqmod/vqmod/wiki/Examples
Scripting: https://github.com/vqmod/vqmod/wiki/Scripting
The problem is the following, in this file footer.tpl
admin/view/template/common/footer.tpl
This is the content:
</div>
<div id="footer"><?php echo $text_footer; ?></div>
</body></html>
And your script want to find this "echo $affiliate;" but this content don't exist in this file.
I don't know what file you want to use, but this file don't has this content
admin/view/template/common/footer.tpl
Regards,
Miguel
i have opencart 1.5.5.1 web site with VqMod(latest)
Vqmod running fine but i had a problem with one xml file.
xlm file has following lines
<file name="admin/view/template/common/header.tpl">
<operation>
<search position="replace" offset="8"><![CDATA[
<ul class="right" style="display: none;">
]]></search>
<add><![CDATA[
<ul class="right" style="display: none;">
<li id="store"><a onClick="window.open('<?php echo $store; ?>');" class="top">
but result was shown below.
File Name : admin/view/template/common/header.tpl(5)
VQModObject::applyMod - SEARCH NOT FOUND (ABORTING MOD): <ul class="right" style="display: none;">
there is a line <ul class="right" style="display: none;">in header.tpl but xml code is not working
Add this code for your replace you want hear:
<file name="admin/view/template/common/header.tpl">
<operation>
<search position="replace"><![CDATA[
<li id="store"><?php echo $text_front; ?>
]]></search>
<add><![CDATA[
<li id="store"><a onClick="window.open('<?php echo $store; ?>');" class="top"><?php echo $text_front; ?></a>
]]>
</add>
</operation>
</file>
This value " <ul class="right" style="display: none;">" is not exactly on this file
admin/view/template/common/header.tpl
Perhaps any other extension changes this file.
Also, you can try to quit this part - offset="8" , here:
<search position="replace" offset="8">
replace for:
<search position="replace">
I tried this, and it is good.
I've followed this small tutorial, and made what i needed:
Stackoverflow - Custom admin page
But now i needed to put a link to it in the admin menu, automaticly when I upload my files to the server...
How can I do it? :s googled for it, but I think I couldn't find the answer :s
This can't be done automatically when you upload the files to the server. You will need to create a vQmod to edit the admin header files to insert it
You should tell us what version of opencart you are using, do you have vqmod (do you intend to use it at all), and where would you like that page link to show up in admin panel.
You need to install vqmod (follow instructions)
create .xml file, save it to vqmod XML folder and put this in it
<modification>
<id>Add a link</id>
<version>1.5.4</version>
<vqmver>0.1</vqmver>
<author>Jeffrey Murdock</author>
<!-- edit header controller -->
<file name="admin/controller/common/header.php">
<!-- create link to your page -->
<operation error="log">
<search position="after"><![CDATA[$this->data['setting'] = $this->url->link('setting/store', 'token=' . $this->session->data['token'], 'SSL');]]></search>
<add><![CDATA[
$this->data['hello_world'] = $this->url->link('custom/helloworld', 'token=' . $this->session->data['token'], 'SSL');
]]></add>
</operation>
<!-- / -->
</file>
<!-- edit header template -->
<file name="admin/view/template/common/header.tpl">
<!-- add link to your page -->
<operation error="log">
<search position="before" offset="1"><![CDATA[<ul class="right">]]></search>
<add><![CDATA[
<li><a class="top">Your link</a>
<ul>
<li>Hello World</li>
</ul>
</li>
]]></add>
</operation>
<!-- / -->
</file>
</modification>
If you installed vqmod properly, and have opencart 1.5.4 version, this should display link in your administrator top menu.