Thanks for anyone who helps or points me in the right direction.
I want to show Order Status in opencart user (My Account) page. It will show status by status ID. My Pending Status ID:1 and I want to show only Pending Status. Other status will not appear.
<?php echo $order_statuses['order_status_id']; ?>
I put this at account.tpl but result error. Please help me.
Maybe need to modify
*english/account/account.php
controller/account/account.php
template/module/account.tpl*
My Open cart Version 1.5.6.3 with custom Theme.
In account.php you have add this.
$this->load->model('account/order');
$results = $this->model_account_order->getOrders(0, 5);
foreach ($results as $result) {
$product_total = $this->model_account_order->getTotalOrderProductsByOrderId($result['order_id']);
$voucher_total = $this->model_account_order->getTotalOrderVouchersByOrderId($result['order_id']);
$this->data['orders'][] = array(
'order_id' => $result['order_id'],
'name' => $result['firstname'] . ' ' . $result['lastname'],
'status' => $result['status'],
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
'products' => ($product_total + $voucher_total),
'total' => $this->currency->format($result['total'], $result['currency_code'], $result['currency_value']),
'href' => $this->url->link('account/order/info', 'order_id=' . $result['order_id'], 'SSL'),
'reorder' => $this->url->link('account/order', 'order_id=' . $result['order_id'], 'SSL')
);
}
In account.tpl add this code
<div id="resent_order" class="recent_order">
<a style="float:right; margin-bottom:15px;" href="<?php echo $manage_order; ?>" class="button">Manage your orders</a><h4>Recent Order</h4>
<ul style="clear:both;">
<?php if( isset($orders) && count($orders > 0 ) ){
foreach ($orders as $order) { ?>
<li>
<div><strong>Order:#</strong><?php echo $order['order_id']; ?></div>
<div><strong>Date:</strong> <?php echo $order['date_added']; ?></div>
<div><strong>Amount:</strong> <?php echo $order['total']; ?></div>
<div><strong>Status:</strong> <?php echo $order['status']; ?></div>
<div class="editPan"><a class="" title="Edit" href="<?php echo $order['href']; ?>">Edit</a></div>
</li>
<?php } ?>
<?php }else{?> <li>You have no recent orders.</li><?php } ?>
</ul>
</div>
Related
I am using opencart 2.3 and in category page, all sub categories have same image. Title is different, in backend and database images are different.
Removed everything from /image/cache with no effect.
Tried to add $image into $data['categories'] array, in controller/product/category.php but is the same.
This is my code from <theme>/product/category.tpl
<?php if ($categories) { ?>
<?php foreach ($categories as $category) { ?>
<img src="<?php echo $thumb; ?>" alt="<?php echo $category['name']; ?>" /><p><?php echo $category['name']; ?></p>
<?php } ?>
<?php } ?>
Can't find nothing else to fix this. Will be very appreciate, if you can help.
Fixed by adding this:
'thumb' => $this->model_tool_image->resize($result['image'], $this->config->get($this->config->get('config_theme') . '_image_category_width'), $this->config->get($this->config->get('config_theme') . '_image_category_height'))
to $data['categories'] array.
:)
Currently my Opencart site only lets me 'Add to Cart' on the categories page, however if a product has options like 'colour' etc I want it to say 'View Product' instead.
Does anyone know how this can be achieved? I have tried editing the category.php controller to check if a product has options but cannot seem to get it working properly.
Thanks.
Update
So far I have added:
$options = $this->model_catalog_product->getProductOptions($result['product_id']);
Above this array $this->data['products'] = array(); in catalog>controller>product>category.php
This was my attempt to check if a product has options or not. Then I added in catalog>view>theme>mytheme>template>product>category.tpl
<?php if ($product['options']) { ?>
<a href="<?php echo $product['href']; ?>" class="button" />View Product</a>
<?php } else { // EO CATALOGUE MODE ?>
<input type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button" />
<?php } ?>
But it is not quite cutting the mustard.
You need to add the options to the $products array which is what you are checking in category.tpl:
Look for:
$this->data['products'][] = array(
'product_id' => $result['product_id'],
and add the options as an index to each product array
$this->data['products'][] = array(
'product_id' => $result['product_id'],
'options' => $this->model_catalog_product->getProductOptions($result['product_id']),
How to print ex-tax amount on featured, bestseller and related module? I tried with $product array but there is no key for ex-tax amount.
Open your bestseller controller file (catalog/controller/module/bestseller.php), and modify this part:
$this->data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'price' => $price,
'special' => $special,
'rating' => $rating,
'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']),
);
... by declaring 2 new variables, called price_ex_tax and special_ex_tax in the products array:
$this->data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'price' => $price,
'price_ex_tax' => $this->currency->format($result['price']),
'special' => $special,
'special_ex_tax' => $this->currency->format($result['special'],
'rating' => $rating,
'reviews' => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']),
);
Then you could access the new variables in the bestseller view file (catalog/view/theme/your_theme_name/template/module/bestseller.tpl). Look for this part:
<?php if ($product['price']) { ?>
<div class="price">
<?php if (!$product['special']) { ?>
<?php echo $product['price']; ?>
<?php } else { ?>
<span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo $product['special']; ?></span>
<?php } ?>
</div>
<?php } ?>
... and replace with:
<?php if ($product['price']) { ?>
<div class="price">
<?php if (!$product['special']) { ?>
<?php echo $product['price'] . "(" . $product['price_ex_tax'] . ")"; ?>
<?php } else { ?>
<span class="price-old"><?php echo $product['price'] . "(" . $product['price_ex_tax'] . ")"; ?></span> <span class="price-new"><?php echo $product['special'] . "(" . $product['special_ex_tax'] . ")"; ?></span>
<?php } ?>
</div>
<?php } ?>
You could repeat the same steps for the featured module as well (controller file: catalog/controller/module/featured.php - view file: catalog/view/theme/your_theme_name/template/module/featured.tpl). You can find the related products in the product controller file (catalog/controller/product/product.php), and you can display it in the product view file (catalog/view/theme/your_theme_name/product/product.tpl). I hope this helped.
For me it worked when I added this to the controller file: catalog/controller/module/featured.php
Just above the $this->data['products'][] = array( add the following line:
$extax = $this->currency->format($product_info['price']);
Then within the array( add:
'extax' => $extax,
Finally go to catalog/view/theme/your_theme_name/template/module/featured.tpl and add:
<?php echo $product['extax']; ?> where you wish to display the price without tax or
<?php echo $product['price'] . "(" . $product['extax'] . ")"; ?> to show both inc and exc, hope that helps.
How i can add options price to cart.tpl ???
i find option price in product.tpl
<?php foreach ($product['option'] as $option) { ?>
- <small><?php echo $option['name']; ?>: <?php echo $option['value']; ?></small><br />
<?php } ?>
Is there a way to add price to this code?
In the product.tpl and the product.php (controller) we have $option_value['price'] but I don't see this in the cart.php or the cart.tpl. How can we pull this variable into the cart and the checkout page to add it?
In the cart.php search for this line
$option_data[] = array(
'name' => $option['name'],
'value' => (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value)
);
Around the line 226 and you can add the price like this
$option_data[] = array(
'name' => $option['name'],
'value' => (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value),
'price' => $this->currency->format($option['price'])
);
// var_dump($option); // look more options
Now in the cart.tpl you can show the price
<?php foreach ($product['option'] as $option) { ?>
- <small><?php echo $option['name']; ?>: <?php echo $option['value']; ?>
price: <?php echo $option['price']; ?></small><br />
<?php } ?>
is there any way to open the product details from category view in a new browser window? The current code for the button is:
<p>
<?php // Product Details Button
echo JHTML::link ($product->link, JText::_ ('COM_VIRTUEMART_PRODUCT_DETAILS'), array('title' => $product->product_name, 'class' => 'product-details'));
?>
</p>
I am using Joomla! 2.5.11 and VM 2.0.22a
In addition to title and class, you can pass third parameter to the array:
array('title' => $product->product_name, 'class' => 'product-details', 'target' => '_blank')
I have changed the following code overriding com_virtuemart/views/category/default.php:
<?php // Product Details Button
echo JHTML::link ($product->link, JText::_ ('COM_VIRTUEMART_PRODUCT_DETAILS'), array('title' => $product->product_name, 'class' => 'product-details')); ?>
To:
<?php $url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $product->virtuemart_product_id . '&virtuemart_category_id=' . $product->virtuemart_category_id . '&tmpl=component'); ?>
...and for the text link:
<a class="product-details" href="<?php echo $product->link ?>" target="_blank"><?php echo JText::_('COM_VIRTUEMART_PRODUCT_DETAILS') ?></a>