How to add column to OpenCart customer list? - opencart

I use OpenCart 1.5.6.4 and 2.3
In admin panel and in customer list there is no column for Customer Id
between this place:

For Opencart 2:
You need to edit this file:
admin/view/template/customer/customer_list.tpl
1)
Find:
<td class="text-left"><?php if ($sort == 'name') { ?>
Add before it:
<td class="text-left">Customer ID</td>
2)
Find:
<td class="text-left"><?php echo $customer['name']; ?></td>
Add before it:
<td class="text-left"><?php echo $customer['customer_id']; ?></td>
For Opencart 1:
This file:
admin/view/template/sale/customer_list.tpl
1)
Find:
<td class="left"><?php if ($sort == 'name') { ?>
Add before it:
<td class="left">Customer ID</td>
2)
Find:
<td class="left"><?php echo $customer['name']; ?></td>
Add before it:
<td class="left"><?php echo $customer['customer_id']; ?></td>
For sort customers by their id for Opencart 2 in step 1 add this code:
<td class="text-left">
<?php if ($sort == 'customer_id') { ?>
Customer ID
<?php } else { ?>
Customer ID
<?php } ?>
</td>
instead of:
<td class="text-left">Customer ID</td>
Then open this file:
admin/controller/customer/customer.php
Find:
$data['sort_name'] = $this->url->link('customer/customer', 'token=' . $this->session->data['token'] . '&sort=name' . $url, true);
Add before it:
$data['sort_customer_id'] = $this->url->link('customer/customer', 'token=' . $this->session->data['token'] . '&sort=customer_id' . $url, true);

Related

how to edit opencart php codes of admin area?

i want to edit and change the admin->catalog->product->edit->option attributes name i.e. price, point and weight to something else. I do it in admin/view/template/product-form.tpl but it does not reflect the change please help.
i change this:
<td class="text-left"><?php echo $entry_subtract; ?></td>
<td class="text-right"><?php echo $entry_price; ?></td>
to this
<td class="text-left"><?php echo "something"; ?></td>
<td class="text-right"><?php echo "something"; ?></td>

Find after pattern plus next line

In a HTML file with some PHP included
<table>
<tbody>
<tr>
<td>td1</td>
<td>td2</td>
</tr>
<tr>
<td colspan="3">
<?php echo 'something' ?>
</td>
<td>
<?php echo echo 'something' ?>
</td>
<td>
<?php echo 'something' ?>
</td>
</tr>
</tbody>
</table>
I'd like to find all <?php that comes after <td ...> + next line.
(Here not td1 and not td2)
Approach:
(?s)(<td.*?>)+(\n)... also matches <td>td1</td> and <td>td2</td>
What comes after (?s)(<td.*?>)?
To remove the <?php...?> you can replace (<td[^>]*>)\s*<\?php.*?\?> by $1:
Explaining:
(<td[^>]*>) # store in $1 what you want to retrieve
\s* # also match what you want to remove
<\?php.*?\?> # the php content
Then when replacing by $1 it will remove only \s*<\?php.*?\?> which depended on <td>
Hope it helps.

Why cart library is not working in codeigniter 3 when using MX hmvc?

Tryint to experiment the cart library, it is working ok without mx hmvc in in CI3. But as soon as i am inserting MX hmvc files (i.e MY_Loader.php and MY_Router.php in application/core folder and MX folder inside third_party folder) it is throwing error saying
Severity: Notice
Message: Undefined property: Welcome::$Session
Filename: MX/Loader.php
Line Number: 171
I am not even inside the modules just trying to use codeigniter's default controller and view.
My modified codeigniter's controller welcome.php is as below
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Welcome extends CI_Controller {
function __construct()
{
parent::__construct();
}
public function index()
{
$this->load->helper('form');
$this->load->helper('url');
// Load the cart library to use it.
$this->load->library('cart');
// Assuming this is the products from our database
$data['products'] = array(
array(
'id' => 'sku_888',
'qty' => 1,
'price' => 39.95,
'name' => 'T-Shirt',
'options' => array('Size' => 'xxx', 'Color' => 'White')
),
array(
'id' => 'sku_888',
'qty' => 1,
'price' => 39.95,
'name' => 'T-Shirt',
'options' => array('Size' => 'xx', 'Color' => 'green')
),
array(
'id' => 'sku_777',
'qty' => 1,
'price' => 9.95,
'name' => 'Coffee Mug'
),
array(
'id' => 'sku_666',
'qty' => 1,
'price' => 29.95,
'name' => 'Shot Glass'
)
);
// Insert the product to cart
if ($this->input->get('id') != '' && array_key_exists($this->input->get('id'), $data['products']))
{
$this->cart->insert($data['products'][$this->input->get('id')]);
}
// Lets update our cart
if ($this->input->post('update_cart'))
{
unset($_POST['update_cart']);
$contents = $this->input->post();
foreach ($contents as $content)
{
$info = array(
'rowid' => $content['rowid'],
'qty' => $content['qty']
);
$this->cart->update($info);
}
}
$this->load->view('welcome_message', $data);
}
}
and the default codeigniter view welcome_message.php, i modified as below
<b>Products</b>
<table width="100%" border="1">
<tr>
<td width="37%">ID</td>
<td width="30%">Name</td>
<td width="16%">Price</td>
<td width="16%"> </td>
</tr>
<?php $product_array_index = 0;?>
<?php foreach($products as $product):?>
<tr>
<td><?php echo $product['id'];?></td>
<td>
<?php
echo $product['name'] ;
if (array_key_exists('options', $product)) {
echo '<hr>';
foreach ($product['options'] as $key => $value)
{
echo '<strong>' . $key . '</strong> : '. $value . '<br/>';
}
}
?>
</td>
<td><?php echo $product['price'];?></td>
<td>Add to Cart</td>
</tr>
<?php $product_array_index ++;?>
<?php endforeach;?>
</table>
<hr>
<b>Your Cart</b>
<?php echo form_open(base_url()); ?>
<table cellpadding="6" cellspacing="1" style="width:100%" border="1">
<tr>
<th>QTY</th>
<th>Item Description</th>
<th style="text-align:right">Item Price</th>
<th style="text-align:right">Sub-Total</th>
</tr>
<?php $i = 1; ?>
<?php foreach ($this->cart->contents() as $items): ?>
<?php echo form_hidden($i.'[rowid]', $items['rowid']); ?>
<tr>
<td><?php echo form_input(array('name' => $i.'[qty]', 'value' => $items['qty'], 'maxlength' => '3', 'size' => '5')); ?></td>
<td>
<?php echo $items['name']; ?>
<?php if ($this->cart->has_options($items['rowid']) == TRUE): ?>
<p>
<?php foreach ($this->cart->product_options($items['rowid']) as $option_name => $option_value): ?>
<strong><?php echo $option_name; ?>:</strong> <?php echo $option_value; ?><br />
<?php endforeach; ?>
</p>
<?php endif; ?>
</td>
<td style="text-align:right"><?php echo $this->cart->format_number($items['price']); ?></td>
<td style="text-align:right">$<?php echo $this->cart->format_number($items['subtotal']); ?></td>
</tr>
<?php $i++; ?>
<?php endforeach; ?>
<tr>
<td colspan="2"></td>
<td class="right"><strong>Total</strong></td>
<td class="right" align="right">$<?php echo $this->cart->format_number($this->cart->total()); ?></td>
</tr>
</table>
<p><?php echo form_submit('update_cart', 'Update your Cart'); ?></p>
How to make it work?

Virtuemart search by country

I want search in my product page for country.To search product by
country. For this i tried to edit the admin panel of virtuemart by
adding country to it.But, its not showing any dropdown.
Added in file- product_edit_information.php
<?php $i = 1 - $i; ?>
<tr class="row<?php echo $i?>">
<td ><div style="text-align:right;font-weight:bold;">
<?php echo JText::_('COM_VIRTUEMART_PRODUCT_COUNTRY') ?></div>
</td>
<td colspan="3">
<select name="mprices[product_currency][0]" id="mpricesproduct_currency0" style="display: none;" class="chzn-done">
<option><?php echo $this->product->product_url; ?></option>
</select>
</td>
</tr>
But, no effect on the admin panel. See the screenshot below:
Also, if possible can anybody suggest a component or module or plugin for coupon system without premium.

Displaying product viewd report in dashboard in opencart

I want to display Product Viewed Report in Dashboard itself. Now the report id under Report->Products->Viewed
How to display it? I tried copying the code from admin->controller->report->product_viewed.php TO admin->controller->common->home.php
and copied the code from admin->view->report->product_viewed.tpl to admin->common->home.tpl
i have added code like this in home.tpl
<div class="content">
<table class="list">
<thead>
<tr>
<td class="left"><?php echo $column_name; ?></td>
<td class="left"><?php echo $column_model; ?></td>
<td class="right"><?php echo $column_viewed; ?></td>
<td class="right"><?php echo $column_percent; ?></td>
</tr>
</thead>
<tbody>
<?php if ($products) { ?>
<?php foreach ($products as $product) { ?>
<tr>
<td class="left"><?php echo $product['name']; ?></td>
<td class="left"><?php echo $product['model']; ?></td>
<td class="right"><?php echo $product['viewed']; ?></td>
<td class="right"><?php echo $product['percent']; ?></td>
</tr>
<?php } ?>
<?php } else { ?>
<tr>
<td class="center" colspan="4"><?php echo $text_no_results; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
in my admin panel-> dashboard i am getting error like this
Notice: Undefined variable: products in /Applications/MAMP/htdocs/opencart/admin/view/template/common/home.tpl on line 95Notice: Undefined variable: column_name in /Applications/MAMP/htdocs/opencart/admin/view/template/common/home.tpl on line 88 Notice: Undefined variable: column_model in /Applications/MAMP/htdocs/opencart/admin/view/template/common/home.tpl on line 89 Notice: Undefined variable: column_viewed in /Applications/MAMP/htdocs/opencart/admin/view/template/common/home.tpl on line 90 Notice: Undefined variable: column_percent in /Applications/MAMP/htdocs/opencart/admin/view/template/common/home.tpl on line 91
please help me in solving this? where i should declare this 'products' ?
What it looks like to me is that there are no results from the products viewed and you have done this transition almost perfectly.
You can either update the language files with the appropriate fields in admin>language>english>common>home.php or you can change the tpl a little like this
<div class="content">
<table class="list">
<thead>
<tr>
<td class="left">Product Name:</td>
<td class="left">Model:</td>
<td class="right">Viewed:</td>
<td class="right">Percent:</td>