Showing posts with label Virtuemart. Show all posts
Showing posts with label Virtuemart. Show all posts

Tuesday, 23 July 2013

Create Facebook comment and Like button for each page ( each Link, each Product)

Create Like Button
- Go to https://developers.facebook.com/docs/reference/plugins/like/
- Clear URL to Like and choice some options by yourself.
- Press Get Code and paste those code on your source code.

Create Comment Facebook
- Go to https://developers.facebook.com/docs/reference/plugins/comments/
- Clear URL to comment on and choice some options by yourself
- Press Get Code and paste those code on your source code with some changes.
- Include code
data-href="http://yourweb.com<?=$_SERVER['REQUEST_URI']?>"
 into this code:
<div class="fb-comments" data-width="470" data-num-posts="10"></div>
This is the final code to put comment box to. Example your website is http://bantudong.com
<div class="fb-comments" data-href="http://bantudong.com<?=$_SERVER['REQUEST_URI']?>" data-width="470" data-num-posts="10"></div>

Sunday, 21 July 2013

Correct Facebook share thumbnail and description - Joomla 2.5 & Virtuemart 2.0

This is a great way to add Open Graph meta tags to the flypage of Virtuemart, to specify the image used by Facebook like, share, send, etc buttons 
I have made some little improvements to your code though, so that it will not be necessary to hard code the domain name of your site and also i added the og::site_name meta tag.
Also I wanted the generated html code to be valid (http://validator.w3.org/) so i had to use addCustomTag() instead of setMetaData() to generate "meta property" instead of "meta name" .

Code: 
$og_type = 'article';
$og_url = JURI::current();
$og_image =  JRoute::_(JURI::base().$this->product->images[0]->file_url);
$og_desc = $this->product->product_s_desc;
$og_title = $this->product->product_name;

$app =& JFactory::getApplication();
$og_sitename = $app->getCfg('sitename');

$doc = JFactory::getDocument();
$doc->addCustomTag('<meta property="og:type" content="article"/>');
$doc->addCustomTag('<meta property="og:url" content="'.$og_url.'"/>');
$doc->addCustomTag('<meta property="og:site_name" content="'.$og_sitename.'"/>');
$doc->addCustomTag('<meta property="og:image" content="'.$og_image.'"/>');
$doc->addCustomTag('<meta property="og:description" content="'.$og_desc.'"/>');
$doc->addCustomTag('<meta property="og:title" content="'.$og_title.'"/>');


This piece of code has to be inserted at the first lines of file "components/com_virtuemart/views/productdetails/tmpl/default.php" just after the line:

Code: 
defined('_JEXEC') or die('Restricted access');
It would be even better if you copy this file at your template directory (folder: templates/my_Joomla_template/html/com_virtuemart/productdetails/) so that it will not be modified by any Virtuemart upgrades.


Check this Change by link:
https://developers.facebook.com/tools/debug

Product sort order on browse/category view - ascending to descending

Problem:
When i show virtuemart home page the product will show in ASC order , (the oldest first) how can i change this with the newest first ?
In the configuration i use date_created_on , if i press this option (in selectbox) is correct but i would that was by default

Solution:
change file: /administrator/components/com_virtuemart/models/product.php
Find the following code:
Code: [Select]
/* invert order value set*/
if ($order =='ASC') {
$orderlink ='&order=DESC';
$orderTxt = JText::_('COM_VIRTUEMART_SEARCH_ORDER_DESC');
} else {
$orderTxt = JText::_('COM_VIRTUEMART_SEARCH_ORDER_ASC');
$orderlink ='';
}

and just switch the order. Be AWARE that this will change all your default sort by to descend.

ALSO, Do you have SEF on or off?

if SEF on, then go to /components/com_virtuemart/router.php.
Inside the file, move the following:
Code: [Select]
if ( isset($query['order']) ) {
if ($query['order'] =='DESC') $segments[] = $helper->lang('orderDesc') ;
unset($query['order']);
}
to after 
Code: [Select]
if ( isset($query['orderby']) ) {
$segments[] = $helper->lang('by').','.$helper->lang( $query['orderby']) ;
unset($query['orderby']);
}

Wednesday, 10 July 2013

Apply Watermark image into Product Image of Virtuemart

Problem: When Creating an shopping website, we would like to apply a watermark image - logo and website name - on every picture of products. It is seem easy by this way: use an watermark program to apply icon on product picture, then upload that picture on hosting. Take a long time if you have over 50 products.
I want to do this work automatically, It means watermark picture will be applied in to all picture (old and new) of website

Solve: I do this work on Joomla 2.5 and Virtuemart 2.0. But I think it is comfortable for every happen load and show Image.
  • Step 1: Create file .htaccess on folder contain image, with Virtuemart 2.0, this folder is <your_domain>/images/stories/virtuemart/product.
    RewriteRule ^(resized)($|/) - [L]
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule \.(gif|jpeg|jpg|png)$ watermark.php [QSA,NC]
  • Step 2: Create file watermark.php at same folder of .htaccess with content:

    <?php
    // watermark.php
    // Path the the requested file
    $path $_SERVER['DOCUMENT_ROOT'].$_SERVER['REQUEST_URI'];
    // Load the requested image
    $image imagecreatefromstring(file_get_contents($path));$w imagesx($image);$h imagesy($image);
    // Load the watermark image
    $watermark imagecreatefrompng('watermark.png');$ww imagesx($watermark);$wh imagesy($watermark);
    // Merge watermark upon the original image (centred)
    imagecopy($image$watermark, (($w/2)-($ww/2)), (($h/2)-($wh/2)), 00$ww$wh);
    // Send the image
    header('Content-type: image/jpeg');imagejpeg($image,null,95);
    exit();
    ?>
  • Step 3: Create an watermark.png with transparent background and upload to that folder.
Done.
Now you can test all image file in folder <your_domain>/images/stories/virtuemart/product have watermark if you call them on your website

Note: the code line RewriteRule ^(resized)($|/) - [L] in .htaccess file ensure that all thumbnail file in resized folder will be not watermarked. If you want to watermark on both thumbnail and large picture, you can remove that line

Demo


Saturday, 6 July 2013

Hide list Catelogy on result Search page format

When we use Virtuemart_search module, list of catelogy will be showed before result list.
Some case, I want to hide this catelogy list and only show result list. This solution I found on internet.

In search module \modules\mod_virtuemart_search\tmpl\default.php  line 4 says:

Code:
<form action="<?php echo JRoute::_('index.php?option=com_virtuemart&view=category&search=true&limitstart=0&virtuemart_category_id='.$category_id )
The result of search is intended to be shown in category view. So, what do we have here? $category_id=0 (parent category!) and sub-categories on top of the default category view, then the list of products (if any), found in our search.

Temporary solution: if we don't need categories in category view, at least in our search result, check if it is a search request. Change line 72 in \components\com_virtuemart\views\category\tmpl\default.php from this:

Code: 
if(!empty($this->category->children)){
to this:

Code:
if(!empty($this->category->children ) && !(boolean)JRequest::getVar('search', false)){

This is my result


How to Show SKU of product in Virtuemart

This is a tip about Joomla and Virtuemart which I found on Internet.

SKU = "Store Keeping Unit". This is an identifier given to each product.
On Virtuemart, you are free to follow any rules to design its value.
If you handle SKUs from other vendors on your store, you may find duplicate values.

In some cases, we want to show this SKU value on product details page, It will be very easy if you know this way:


  1. Find this file on your hosting in order to edit it: <your_site>/components/com_virtuemart/views/productdetails/tmpl/default.php
  2. Choice position you want to show SKU and add this code:
    <?php // Product SKU     ?>
        <h1>
        <?php echo 'SKU: '?>
        <?php echo $this->product->product_sku ?>
        </h1>
  3. You don't need use tag <h1>.
Demo:

Before



After