Thursday, 28 July 2016

Product Condition (Add/delete/rename) Prestashop 1.5+

Product Condition Prestashop 1.6+

 In the Prestashop v 1.5+, when we insert a new product, there is the possibility to set the product condition. There are 3 condition: new, used, refurbished.  

Can we add, delete or rename the conditions?

I found about the ENUM value in the "ps_product" database table and in some file of the admin controllers and in product classes.

solution in PS 1.6.1.4

1. edit in db enum - table ps_product_shop & ps_product row condition
2. in ~/admin/themes/default/temlapte/controller/products/informations.tpl
3. in ~/themes/you_theme_name/product.tpl
4. in ~/classes/Product.php
5. in ~/modules/blocklayered/blocklayered.php

==================================

you have to modify product.tpl file located in your theme directory, there is a code like:
{capture name=condition}     
{if isset($product.condition) && $product.condition=="new"}
    <div class="label-wrapper wrapper-new cls_new">
        <div class="label label-new">{l s='New' mod='jmsproductfilter'}</div>
    </div>  
{elseif isset($product.condition) && $product.condition == "pricedrop"}
    <div class="label-wrapper wrapper-new cls_pricedrop">
        <div class="label label-new">{l s='Price Drop!' mod='jmsproductfilter'}</div>
    </div>  
 {elseif isset($product.condition) && $product.condition == "bestvalue"}
    <div class="label-wrapper wrapper-new cls_bestvalue">
        <div class="label label-new">{l s='Best Value!' mod='jmsproductfilter'}</div>
    </div>
  {elseif isset($product.condition) && $product.condition == "latest"}
    <div class="label-wrapper wrapper-new cls_latest">
        <div class="label label-new">{l s='Latest' mod='jmsproductfilter'}</div>
    </div>
 {elseif isset($product.condition) && $product.condition == "dailyshiping"}
    <div class="label-wrapper wrapper-new cls_dailyshiping">
        <div class="label label-new">{l s='Daily Shipping' mod='jmsproductfilter'}</div>
    </div>
 {elseif isset($product.condition) && $product.condition == "onstock"}
    <div class="label-wrapper wrapper-new cls_onstock">
        <div class="label label-new">{l s='On Stock' mod='jmsproductfilter'}</div>
    </div>                             
{/if}

Monday, 18 July 2016

iPad/iPhone hover problem causes the user to double click a link

I have some websites I built times ago, that use jquery mouse events...I just got an ipad and i noticed that all the mouse over events are translated in clicks...so for instance i have to do two clicks instead of one..(the first hover, than the actual click)

Haven't tested this fully but since iOS fires touch events, this could work, assuming you are in a jQuery setting.

$('a').on('click touchend', function(e) {
    var el = $(this);
    var link = el.attr('href');
    window.location = link;
});
 
The idea is that Mobile WebKit fires a touchend event at the end of a tap so we listen for that and then redirect the browser as soon as a touchend event has been fired on a link.

OR you can trigger on click of parent div

$(document).on('click', '.clickable-div', function() {

    document.location = $(this).data('href');

});
 
Using css style : I've found this the easy fix, simply add this to the css

<style>
    .clickable-div 
    {
         cursor: pointer;
    }
</style>

Create social share buttons with custom icons

Over the years, social media has become one of those inevitable elements in our lives that you just can’t escape, even if you wanted to.

Twitter

http://twitter.com/intent/tweet?status=[TITLE]+[URL]

Pinterest

http://pinterest.com/pin/create/bookmarklet/?
media=[MEDIA]&url=[URL]&is_video=false&description=[TITLE]

Facebook

http://www.facebook.com/share.php?u=[URL]&title=[TITLE]
According to Frédéric, supposedly the URL syntax above for Facebook has been deprecated, even though so far it seems to be still working for me, but just in case here is the new one for future reference.
http://www.facebook.com/sharer/sharer.php?u=[URL]&title=[TITLE]
 
 
Facebook no longer supports custom parameters in sharer.php
But this is not entirely correct. Well, maybe they do not support or endorse them, but custom parameters can be used if you know the correct names. These include:
  • URL (of course) → u
  • custom image → picture
  • custom title → title
  • custom quote → quote
  • custom description → description
For instance, you can share this very question with the following URL:
https://www.facebook.com/sharer.php?caption=[caption]&description=[description]&u=[website]&picture=[image-url]
 
 

Google+

https://plus.google.com/share?url=[URL]

Reddit

http://www.reddit.com/submit?url=[URL]&title=[TITLE]

Delicious

http://del.icio.us/post?url=[URL]&title=[TITLE]&notes=[DESCRIPTION]

Digg

https://digg.com/submit?url=[URL]&title=[TITLE]

Tapiture

http://tapiture.com/bookmarklet/image?img_src=[IMAGE]&page_url=[URL]&
page_title=[TITLE]&img_title=[TITLE]&img_width=[IMG WIDTH]img_height=[IMG HEIGHT]

StumbleUpon

http://www.stumbleupon.com/submit?url=[URL]&title=[TITLE]

Linkedin

http://www.linkedin.com/shareArticle?mini=true&url=[URL]&
title=[TITLE]&source=[SOURCE/DOMAIN]

Slashdot

http://slashdot.org/bookmark.pl?url=[URL]&title=[TITLE]

Technorati

http://technorati.com/faves?add=[URL]&title=[TITLE]

Posterous

http://posterous.com/share?linkto=[URL]

Tumblr

http://www.tumblr.com/share?v=3&u=[URL]&t=[TITLE]

Google Bookmarks

http://www.google.com/bookmarks/mark?op=edit&bkmk=[URL]&title=[title]&
annotation=[DESCRIPTION]

Newsvine

http://www.newsvine.com/_tools/seed&save?u=[URL]&h=[TITLE]

Ping.fm

http://ping.fm/ref/?link=[URL]&title=[TITLE]&body=[DESCRIPTION]

Evernote

http://www.evernote.com/clip.action?url=[URL]&title=[TITLE]

Friendfeed

http://www.friendfeed.com/share?url=[URL]&title=[TITLE]
This a great list listing most popular social services but I have struggled finding what the syntax for an email button should be like. If you are a developer, you are most likely familiar with syntax for an email link. What you need to accomplish the desired outcome, your markup should looks something along these lines:
<a href="mailto:?subject=[TITLE]&body=Check out this site I came across 
[URL]">[EMAIL]</a>

Follow Buttons

I’ve been just recently asked if I knew about a way to create a “follow” buttons without any plugin. So far I’ve only looked into Twitter’s syntax for a follow button and this is what I got:
<a href="https://twitter.com/intent/follow?original_referer=[URL]/&
region=follow_link&screen_name=[YOUR TWITTER HANDLE]&tw_p=followbutton" 
onclick="_gaq.push(['_trackEvent', 'outbound-article', 
'https://twitter.com/intent/follow?original_referer=
[URL]/&region=follow_link&screen_name=[YOUR TWITTER HANDLE]&tw_p=followbutton', 
'Follow @[YOUR TWITTER HANDLE]']);">Follow @[YOUR TWITTER HANDLE]</a>
 
Having this site in WordPress, I wanted to test it of course. Using WordPress codex functions, all I had to do was to substitute the [TITLE] with:

<?php print(urlencode(the_title())); ?>
…and [URL] with:
 
<?php print(urlencode(get_permalink())); ?>
 
I hope you find this information helpful for creating social media buttons with custom icons. Feel free to let me know in comments below.

Wednesday, 6 July 2016

WordPress building simple menu list wp_get_nav_menu_items()

Get the nav menu based on $menu_name (same as 'theme_location' or 'menu' arg to wp_nav_menu)

$menu_name = 'short-menu';

    if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_name ] ) ) {
  $menu = wp_get_nav_menu_object( $locations[ $menu_name ] );

  $menu_items = wp_get_nav_menu_items($menu->term_id);

  $menu_list = '<ul id="menu-' . $menu_name . '">';

  foreach ( (array) $menu_items as $key => $menu_item ) {
   $title = $menu_item->title;
   $url = $menu_item->url;
   $menu_list .= '<li><a href="' . $url . '">' . $title . '</a></li>';
 }
  $menu_list .= '</ul>';
    } else {
  $menu_list = '<ul><li>Menu "' . $menu_name . '" not defined.</li></ul>';
    }
 
 
// $menu_list now ready to output
echo $menu_list;