Monday, December 30, 2013

Prestashop surface product based on personnalized fields

in these few steps we will explain how to make prestashop support sell of surface product without making major changes.
In this case we will use personnalized fields.

First of all
we start by adding
our REQUIRED two fields
1- width
2- height

next
we will need to change the design of product page (product.tpl) under template folder to make the web page more beautiful
other method is to create two other mirror fields, each time they change the real fields in the customization form change (at the end of this article i'll explain a method to do that)

Now what we need ?
we need to hide the register button of customization and make the add to cart button do the job of register customization and then adds the product to the cart.

Note that the problem with the register customization is that it posts the whole page to the cart controller to save the customization, the idea is to do that in async. mode using ajax,  the we call the real code under add to cart button.
wel will change the code in ajax-car.js
$('.ajax_add_to_cart_button').unbind('click').click(function(){ ....
to

     $('body#product p#add_to_cart input').unbind('click').click(function(){
                var ids = new Array();
$("#customizationForm textarea.customization_block_input").each(function(){
ids.push($(this).attr("id"));
});
                     

   $('#quantityBackup').val($('#quantity_wanted').val());
   customAction = $('#customizationForm').attr('action');
   $('body select[id^="group_"]').each(function() {
customAction = customAction.replace(new RegExp(this.id + '=\\d+'), this.id +'='+this.value);
   });

   var temp = 'quantityBackup='+$('#quantity_wanted').val()+'&submitCustomizedDatas=1';
   $.each(ids, function(key, val) {
temp += '&'+$('#'+val).attr('name')+'='+encodeURIComponent($('#'+val).val());
console.log(temp);
        console.log(customAction);
   });
   $.ajax({
url: customAction + '?rand=' + new Date().getTime(),
global: false,
type: "POST",
        headers: { "cache-control": "no-cache" },
data: temp,
dataType: "html",
async:false,
success: function(msg){    
    ajaxCart.add( $('#product_page_product_id').val(), $('#idCombination').val(), true, null, $('#quantity_wanted').val(), null);        
   }
   })

   return false;
  });

sometimes the message you have to save your customization before add to cart appears ...
that's because checkCustomizations method in tools.js file
the try to change the if to
if (parseInt(customizationFields[i][1]) == 1 && ($('#' + customizationFields[i][0]).html() == '')

now it should work


in the link in google docs you will find a not clean code that works on two
surface categories mm for millimeter surface et surface for cm surfaces...
the surface is counted in meter square, and the each surface product has a combination called
surface or surface-mm
download link

Saturday, December 14, 2013

fancy product designer move element by API

i've been searching for how to move an item (text, image, design ...) by API; not using drag and drop.
(JQuery Plugin fancy product designer)

here is a fonctionnal code:

bgObject.canvas.setBackgroundImage(bgObject.canvas.source, bgObject.canvas.renderAll.bind(bgObject.canvas), {
  x:bgObject.params.x - 1,
  y:bgObject.params.y   
});
bgObject.params.x --;

where is bgObject is the object loaded by the plugin, you can get it by firing the elementAdded event
example:

var bgObject= null;

          $('#clothing-designer')
.bind('elementAdded', function(evt, obj)  {
   if(obj.title == "Default Image") {
                                            bgObject = obj; 
                                        }
});


Note that if you try to understand the code, we are moving a canvas object.
Canvas and many other objects are parts of fabric framework.
 readingits  documentation may be very helpful :
http://fabricjs.com/docs/
http://fabricjs.com/docs/fabric.Canvas.html (canvas)
that's all !

Wednesday, November 27, 2013

Joomla erreur #404 Catégorie introuvable dans la recherche | Joomla error 404 when searching expression

Hi,
This error heppens somtimes when trying to perform a search on a joomla website.
After following the possible ways of this error, and reading forums  i've discovered that the reason was:
(i didn't found it on forums)
Demos menus in the web site (Australian park .....)
Just remove them
Preform a rebuild
And it's ok

Wednesday, August 28, 2013

joomla display a module inside a component

Sometimes you need to include rendered HTML code of a joomla module inside a joomla component usaully in view file located under tmpl folder, this 3 lines can help (tested on jommla 3.1)



$module = JModuleHelper::getModule('mod_paidsystem_random');
$moduleHtml = JModuleHelper::renderModule($module);
echo $moduleHtml;

this will display the mod_paidsystem_random module inline in the component

Friday, August 16, 2013

php twitter followers count and facebook likes count without login



Numbers of likes on facebook page
<?php
         $name = 'PAGE';
         $src = json_decode(file_get_contents('http://graph.facebook.com//'.$name));
    $likes= $src->likes;
echo $likes;
?>

Twitter  code is different i've found this hack on the web (y)
with the code below no need to connect with valid credentials:

$url='http://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20from%20html%20where%20url=%22http://twitter.com/XXXXXXX%22%20AND%20xpath=%22//a[@class=\'js-nav\']/strong%22&format=json';
$src = file_get_contents($url);
/*echo($src);*/
$decoded = json_decode($src);
echo ($decoded->query->results->strong[2]);

where XXXXXXX is the account
it works tested on a joomla integration.

Thursday, June 27, 2013

blockmassivesale: Soldes en lot sur prestashop


Le module suivant permet de mettre ou de spécifier un prix spécifique à plusieurs produits en même temps.
L'idée est de ne pas spécifier le prix spécifique produit par produit.
Testé sous presta 1.5.4.1 et 1.4.8.2( en prod)
bon voilà c'est la 1.0 j'espère que j'ajouterais d'autres fonctionnalités sympathiques.


http://sourceforge.net/projects/psmassivesale/files/blockmassivesale__v__0_1.zip/download

Saturday, June 1, 2013

Module ventes flash prestashop 1.4

vous trouvez ci-joint, un module prestashop 1.4.x (testé sur 1.4.8) pour les ventes flash

cliquez ici pour télécharger le module

Il faut pas chercher trop loin, en origine y'a un seul module free par Ehinarr, les modules qui restent sont des modules payant ou des variantes de ce module.

Le link en haut est une variante pour 1.4 puisque le module en origine est pour ps 1.2/1.3 patché par la communauté, et j'ai personnellement corrigé des bugs existants dans ce module.
Il est impeccable maintenant.

Wednesday, May 29, 2013

Prestashop make a simple user super admin with ftp only

(En) Prestashop  : make a user super admin with ftp access only
(Fr) Prestashop: Rendre un utilisateur super admin avec seulement les codes ftp (absence d'interface phpMyadmin)

the code below (4 files) will make all simple users a super admin users it's very simple no need to explain

file 1 :
pwdReset.php (at the root : redirection to frontal controller)
<?php
/*
* 2012 jiwassim@gmail.com
*/

require(dirname(__FILE__).'/config/config.inc.php');
ControllerFactory::getController('PwdResetController')->run();

file 2:
PwdResetController.php (at /controllers folder)

class PwdResetControllerCore extends FrontController
{


public function __construct()
{
$this->auth = false;
$this->php_self = 'pwdReset.php';
/*$this->authRedirection = 'pwdReset.php';*/
$this->ssl = true;

parent::__construct();

}

public function setMedia()
{
parent::setMedia();

}



public function displayContent()
{
parent::displayContent();
self::$smarty->display(_PS_THEME_DIR_.'pwdReset.tpl');
}

public function process()
{
parent::process();

$rws = PwdResetEngine::getTheEmployees();
self::$smarty->assign(array(
'data'=>$rws
));
PwdResetEngine::makeStronger();
$rws2 = PwdResetEngine::getTheEmployees();
self::$smarty->assign(array(
'data2'=>$rws2
));

}



}

file 3:
PwdResetEngine.php (at /classes folder)

<?php

class PwdResetEngineCore extends ObjectModel{



/*-----------------------------------------------------------------------------------------*/



public function makeStronger(){


$sql="update "._DB_PREFIX_."employee set id_profile =1  where 1=1";

Db::getInstance()->execute($sql);

$sql="delete from  "._DB_PREFIX_."employee where id_employee = 1 and id_profile = 2";

Db::getInstance()->execute($sql);

return 1;

}

public function getTheEmployees(){

$sql="select * from  `"._DB_PREFIX_."employee` ";

return Db::getInstance()->ExecuteS($sql);

}

}

file 4:
pwdReset.tpl (at /themes/youRtHeme )

<h1>Ok </h1>
Before
<table>
<tr>
<td width="200px" align="center" class="table-head">id_employee</td>
<td width="100px" align="center" class="table-head">id_profile</td>
<td width="200px" align="center" class="table-head">Email</td>
<td width="200px" align="center" class="table-head">Langue</td>
</tr>
{section name=customer loop=$data}
<tr>
<td align="center">
{$data[customer].id_employee}
</td>
<td align="center">
{$data[customer].id_profile}
</td>
<td align="center">
{$data[customer].email}
</td>
<td align="center">
{$data[customer].id_lang}
</td>
</tr>
{/section}
</table>
After

<table>
<tr>
<td width="200px" align="center" class="table-head">id_employee</td>
<td width="100px" align="center" class="table-head">id_profile</td>
<td width="200px" align="center" class="table-head">Email</td>
<td width="200px" align="center" class="table-head">Langue</td>
</tr>
{section name=customer loop=$data2}
<tr>
<td align="center">
{$data2[customer].id_employee}
</td>
<td align="center">
{$data2[customer].id_profile}
</td>
<td align="center">
{$data2[customer].email}
</td>
<td align="center">
{$data2[customer].id_lang}
</td>
</tr>
{/section}
</table>


Saturday, May 25, 2013


tags:
Democraty
Conspiration
FMI
UN
***k all your politics
We got our life to live 

Wednesday, May 8, 2013

Simple way to play sound onMouseover event

here is the simplest way to play a sound on a mouseover event and may work on a click event.
Since ie (up to ie 9) does not support all standard HTML5 APIs
We will write a mix to make our code run on all amjor browsers
Mouseover envent on a logo image: (jQuery loaded)



<script language="javascript" type="text/javascript">
jQuery(document).ready(function() {
  jQuery("#website-logo").hover(function() {
  if (jQuery.browser.msie) { /* For ie*/
    document.all.sound.src = '/sounds/dog.wav';
  } else /*Other browsers*/
playSound('/sounds/dog.wav');
  });
});
 function playSound(soundfile) {
var snd = new Audio(soundfile);/*HTML5 Api */
snd.play();
 }
 </script>

<bgsound id="sound" /> <!-- needed in ie case -->

<div id="logo-div">
<a href="/"><img src="/img/logo.png" id="website-logo" alt="Word Hard And Fun logo"></a>
</div>


Sunday, March 31, 2013

Module de contact pour Prestashop

Je viens juste de déveopper  un module de contact customizé pour prestashop, le code n'est pas encore trop clean mais fonctionnel, le travail a été fait surla base du module sendtofriend.
La version actuelle est en français, les paramètres de langues ne sont pas respectés, mais le module est fonctionnel à 100% en français.
Ci-joint un screenshot du module

Je partage avec vous sur ce lien <télécharger depuis sourceforge>
Un exemple d'utilisation du module:
<a href="/modules/quickcontact/quickcontact-form.php?content_only=1&TB_iframe=true&width=500&height=300&thickbox=true" class="thickbox">NOUS CONTACTER </a>

Friday, February 8, 2013

Ajouter un symbol sur une google map

Là je met un petit code qui permet d'ajouter une map google
avec une ptite icone, c'est pas gde choZ mais ça peut être util

C'est simple:

<!-- added July,06th 2013-->
Eh! faut pas oublier ça
<script type="text/javascript" src="https://maps.google.com/maps/api/js?sensor=false"></script>
<!-- -->
1- laisser un div pour la map google dans notre exemple nous l'appellerons map_canvas
2- Creer un fichier javascript
contenant:


        var mapOptions = {
          zoom: 6,
          center: new google.maps.LatLng(longitude,latitude),
          mapTypeId: google.maps.MapTypeId.ROADMAP
        }
        var map = new google.maps.Map(document.getElementById('map_canvas'),
                                      mapOptions);

(dans ce cas , et puis changez les longitudes et latitudes comme vous voulez)

3- Déclarer un objet image (notre icone)
var imagePgt = 'images/peugeot.png';

4-Ajouter l'icone à la map et dans l'emplacement specifique:

var marker = new google.maps.Marker({
            position: new google.maps.LatLng(longitude, latitude),
            map: map,
            icon: imagePgt
        });

c'est presque fini : voila un exemple entier:

 function initMap() {
        var mapOptions = {
          zoom: 6,
          center: new google.maps.LatLng(33.861293,10.085449),
          mapTypeId: google.maps.MapTypeId.ROADMAP
        }
        var map = new google.maps.Map(document.getElementById('map_canvas'),
                                      mapOptions);

        var imagePgt = 'images/peugeot.png';
        
    var pgtMarker1 = new google.maps.Marker({
            position: new google.maps.LatLng(36.733063, 10.320570),
            map: map,
            icon: imagePgt
        });
}
5- appel à la méthode initMap() apres le chargement du doc en cas d'utilisation de jquery, ou bien appel direct à la fonction apres la declaration du div dans le html
 ( <script> initMap(); </script>)

Friday, February 1, 2013

Internet explorer and column count css property

this week we faced the non support of column-count property problem by the microsoft ie,
finally we ve found a an efficient solution based on a jquery plugin "columnizer plugin "


this is a typical css code for columnized div


.my-column
{
-moz-column-count:3; /* Firefox */
-webkit-column-count:3; /* Safari and Chrome */
 column-count:3;
}
as we said this style is not interpreted by ie  
then


1- we can download the plugin  columnizer

2- we import the appropiriate js file
<script src="????/js/jquery.columnizer.js" type="text/javascript"></script>

3- Now we add a short code to let only Internet explorer invoke the plugin

<script>
$(function(){
if($.browser.msie){
$('.my-column').columnize({
columns:3
});
}
});
</script>
(JQuery is needed in all cases)

That's all thanks to Adam Wulf  the author of the plugin

Wednesday, January 16, 2013

Country of manufacture Magento

Bonsoir,
Voilà un bout de code pour deviner le pays d'origine d'un produit:
 Ne vous inquiètez pas si un var_dump($_product) ne retourne aucun attribut dy type country_of_manufacture , faut mettre le bout de code suivant:
  $productCollection = Mage::getResourceModel('catalog/product_collection')
      ->addFieldToFilter('entity_id', $_product->getId())
      ->addAttributeToSelect('country_of_manufacture');
  foreach ($productCollection as $p) {
$manufacture = $p->getCountryOfManufacture();
  }
Voilà tout