
A customer can reach to a product page from the front page, ‘Most sold’ and ‘New product’ on the right column and a category page.
Download Page
We will display all the information which we entered in the back-end. A large image, name, short description, long description, price and a BUY link which add the product details in a shopping cart and display a message to notice the customer that it added the product to the shopping cart.
webshop controller
You need to add the following function product() to module/webshop/controllers/webshop.php.
I am not using colors and sizes for the webshop. However I kept these features, so if you need, you can use them for your webshop.
The details are commented in the code.
function product($id){
$product = $this->MProducts->getProduct($id);
/** this returns all, i.e. id, name, shortdesc, longdesc, thumbnail,
* image, grouping, status, category_id, featured and price
* from product db.
*/
if (!count($product)){
// no product so redirect
redirect( $this->lang->line('webshop_folder').'/index','refresh');
}
$data['product'] = $product;
$data['title'] = $this->lang->line('webshop_shop_name')." | ". $product['name'];
// I am not using colors and sizes, but you can.
$data['assigned_colors'] = $this->MProducts->getAssignedColors($id);
$data['assigned_sizes'] = $this->MProducts->getAssignedSizes($id);
$data['page'] = $this->config->item('backendpro_template_shop') . 'product';
$data['module'] = $this->lang->line('webshop_folder');
$this->load->view($this->_container,$data);
}
view/product.php
module/webshop/views/shop/product.php
<div id='pleft'>
<?php
if ($this->session->flashdata('conf_msg')){
echo "<div class='status_box'>";
echo $this->session->flashdata('conf_msg');
echo "</div>";
}
?>
<?php
echo "<img src='".$product['image']."' border='0' align='left'/>\n";
echo "<div id=\"procont\"><h2>".$product['name']."</h2>\n";
echo $product['shortdesc'] . "<br />\n";
echo $product['longdesc'] . "\n";
echo "<br />";
echo "<p><b>".$this->lang->line('webshop_price')."</b>: ". $this->lang->line('webshop_currency_symbol'). $product['price']. "</p>\n";
echo '<p><a class="cartlinkbut" href="' . site_url()."/".
$this->lang->line('webshop_folder').'/cart/'.$product['id'].
'"><span class="addtocart addcart">'.$this->lang->line('webshop_buy').'</span></a></p></div>';
?>
</div>
‘BUY’ has a link to a shopping cart.
I am using $this->lang->line(‘webshop_price’) for Price so that it is easy to convert to other languages. You just need to create a language folder and file. For example, module/webshop/language/norwegian/webshop_lang.php.
And you just need to load it instead of English.
If you are using more than one language, you can find a nice library or helper in Codeigniter wiki.































[...] Codeigniter shopping cart v1.1 Part 12: product page [...]
Hi
I tried downloading and installing your freshly published Shopping cart V1.1
a great share Thanks. I’ll be sharing back anything I can return to you.
the back end works great but I guess there’s something missing for the Front End (probably Webshop )
there’s no controler and in the routes the route is directed to “webshop”
and the webshop Tutorial doesn’t have any controler
I must be missing something .
on the root of my site I get this :
An Error Was Encountered
Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.
REgards
Tibor
Hi
just your info in your quickSand demo
quicksand_temp & quicksand_temp_ajax
containe short tags which aren’t default installed everywhere
Regards
Tibor
@Tibor: No, the download zip for V1.1 does not have any webshop folder/files at the moment. I wrote it in the download page telling that you need to follow the articles to build up the module. It’s part of learning, I hope. When the series finishes, I will add it.
Shinokada thankyou!
I’m really learning a lot from your tutorials.
Shinokada,
I read the entire topic of BEP on codeigniter’s site, and I can’t find the way to translate the interface of BEP. Is the only way to do this task to replace every array item in the backendpro_lang.php file?
And to translate the shopping cart?
Shinokada,
Ok, I found the way to translate BEP. Making a spanish folder in every languaje where a languaje folder is needed. But is this ok? I’ve seen other systems where lang files are all centralized in one place.
Thanks for taking time to share with us!
I think you are not just doing great job with this but also using the best way publish a professional tutorial.
There are couple of ways to do it. One way is you can load your language and module_language file and put all your translation there.
$this->load->module_language(‘webshop_folder’,'webshop’);
[...] Codeigniter shopping cart v1.1 Part 12: product page [...]
[...] Shopping cart v1.1 Pаrt 12: product page | Okada Design Blog [...]