gonebdg - webindoshop.com - Viewing Profile: Likes - PrestaShop

Jump to content

gonebdg - webindoshop.com

Member Since 17 Jul 2009

Offline Last Active May 23 2017 05:39 AM
*****

#2459351 how encrypt string to password?

Posted by gonebdg - webindoshop.com on 03 December 2016 - 09:17 AM

Example

<?php
use PrestaShop\PrestaShop\Adapter\ServiceLocator;

class YourClassName extends Something
{
    public static function MyFunction($plaintextPassword)
    {    
        try {
            /** @var \PrestaShop\PrestaShop\Core\Crypto\Hashing $crypto */
            $crypto = ServiceLocator::get('\\PrestaShop\\PrestaShop\\Core\\Crypto\\Hashing');
        } catch (CoreException $e) {
            dump($e); // if error dump feel free to modify as you need
        }

        $hash_password = $crypto->hash($plaintextPassword);
        return $hash_password;
    }
}

Next you can use the method to generate hash password

<?php
// ... your php content

// for example we will hass password 12345678
// this will generate somthing like $2y$10$dcPc7q9YJdPRQnBT1gyC2e.wHSRSppwsHe4tDvSqkjOw4aYZLUq9
$hass_password = YourClassName::MyFunction(12345678);

// it will return different hash password each time you use it
// but the first 7 characters within the generated hash password will remain the same, e.g : $2y$10$
// it will return true if you use $crypto->checkHash(12345678, HASH_PASSWORD); to Check the password



#2135286 Remove Delivery and Invoice Address fields in the Guest Checkout (PS 1.6)

Posted by gonebdg - webindoshop.com on 02 September 2015 - 07:51 AM

Ok let's continue.

3rd, modify theme file order-opc-new-account.tpl to create dummy address by defining default field value

If the 1st step already done correctly, then only: addrees, city, country, and alias are the required fields.

Add following smarty code on the top of the file :

{assign var=default_address value='My address'}
{assign var=default_city value='My city'}
{assign var=default_country value='DEFAULT_COUNTRY_ID'}
{assign var=default_alias value='My dummy address'}

Attention! replace DEFAULT_COUNTRY_ID with your default country ID

Feel free to change the value for the others dummy var as you wish

 

Then for each corresponding HTML input, put the dummy smarty variable as the input value

Below are an example about how to defining default value for field address1

{* commenting the original smarty code OR you might remove it completely
<input type="text" class="text form-control validate" name="address1" id="address1" data-validate="isAddress" value="{if isset($guestInformations) && isset($guestInformations.address1) && isset($guestInformations) && isset($guestInformations.address1) && $guestInformations.address1}{$guestInformations.address1}{/if}" />
*}
<input type="text" class="text form-control validate" name="address1" id="address1" data-validate="isAddress" value="{$default_address}" />

Do the same procedure for city and alias

 

Except for country field input, we need to remove the original field (HTML select) and create a hidden input field

{* commenting the original smarty code OR you might remove it completely
<select name="id_country" id="id_country" class="form-control">
   {foreach from=$countries item=v}
      <option value="{$v.id_country}"{if (isset($guestInformations) && isset($guestInformations.id_country) && $guestInformations.id_country == $v.id_country) || (!isset($guestInformations) && $sl_country == $v.id_country)} selected="selected"{/if}>{$v.name|escape:'html':'UTF-8'}</option>
   {/foreach}
</select>
*}
<input type="hidden" name="id_country" id="id_country" value="{$default_country}" />

That's it, now all required fields for address have default value, so customers doesn't have to fill an address, however if the 2nd step above already done correctly then there is no address fields displayed on the form.




#2120799 Solved - Blocklayered navigation not working with cache active

Posted by gonebdg - webindoshop.com on 13 August 2015 - 08:00 AM

I had a demo site running with memcached and no issue found.

When i've read this thread, i'm trying to use APC caching system for my Dev.Site on localhost using virtual machine, and indeed there is a problem with blocklayered.
And this problem also happen if we use File System for the caching system.
Not sure if this also happen if we use Xcache for the caching system.

Linux #40~14.04.1-Ubuntu
Apache
PHP Version 5.5.9-1
APCu Version 4.0.7
PrestaShop v.1.6.1.0
Blocklayered v2.1.0

So ... I'm thingking how to clear the cache when the blocklayered filter is use, then I found out that flushing the apc cache fix the problem, as described on my previous post above.
Basically it execute default php function to clear APC cache with apc_clear_cache()
//php.net/manual/en/function.apc-clear-cache.php

But flushing the cache is not work if we use File System for the caching system, but delete cache directory will fix the problem.
CacheFs::deleteCacheDirectory();

$cache = Cache::getInstance();
if (get_class($cache) == 'CacheApc')
    $cache->flush();
elseif (get_class($cache) == 'CacheFs')
    CacheFs::deleteCacheDirectory();

However as I said before that was just a quick fix, and may not the best solution.
Because flushing or deleting cache, remove the advantage from the use of the caching system itself eventhough it only for the blocklayered module.




#2118762 PrestaShop Image ALT Tags Per Image Upload

Posted by gonebdg - webindoshop.com on 10 August 2015 - 07:47 PM

And no. They core doesn't support what I have requested. You change ALL of the ALT tags to be the same. That isn't good image SEO practice.

 

No, in PS v.1.6.1.0 you can update each image caption, please see my attachment image on the previous post above.
There is a drop down where you can select which image will be associated with the captions, and this captions image will be used as value for the title and alt of the img tag (default-bootstrap theme)

 

The dropdown will have an options something like this :

All captions   --> If you want to change all image captions

Position 1     --> If you want to change image captions for the product image at position 1

Position 2     --> If you want to change image captions for the product image at position 2

Position 3     --> If you want to change image captions for the product image at position 3

Position 4     --> If you want to change image captions for the product image at position 4

 

For more detail, see ../controllers/admin/AdminProductsController.php   public function processImageLegends()




#2116592 [SOLVED] Add color name from colorPickerClick selection to product page

Posted by gonebdg - webindoshop.com on 07 August 2015 - 05:31 AM

Thank you! but applying the code above does not allow people to select the color on the page...

 

I believe there is a syntax error at:

for (var i=0; i<nb_attr i++)

Hmm... so I added a semi colon as seen below... and now I can select color again BUT

for (var i=0; i<nb_attr; i++)

With above line... upon page refresh... the default color is selected and the text is still the default as well... Also the page ends up looking a little odd like something became corrupted hmm... so seems something further is an issue.

 

I really thank you for the help so far however... seems like unlocking this answer is soon!

 

Ah yes you're right, there is a typo ... missing semi colon.

 

Not sure how you implement it within your PrestaShop, but those modification is to show the selected attribute value (in this case, color value) on the corresponding html tag according to specified ID.
Can you share the screenshots and show me the problem to know the end result that you want to accomplish?

 

Edited

i've manage my time and try to implement this to my demo site (PrestaShop v.1.6.0.14), and everything are working well.
But I've realized, there is a small difference about the combination parameter on the URL on my previous example
It was stated as

//domain.com/product.html#/1-color-blue/ (pay attention, there is an id here)

array[0] => 1

array[1] => color

array[2] => blue

But then in fact there is no id within the combination parameter on the URL
//domain.com/product.html#/color-blue/

array[0] => color

array[1] => blue

So, you should change my previous modification script as follow :

// define new variable for selected color with value false
var selectedColor = false;

// count number of combinations from the URL
var nb_attr = tabParams.length;

// get the color value from the loop ; Attention! Changes was made to this part, read all new comments below
for (var i=0; i<nb_attr; i++)
{
      // previously the array key used on the if statement was defined as 1
      // but because there is no id within the combination parameter on the URL
      // we should change the array key as 0
      // and change the array key used to get the color value as 1
      // In here i'm also adding small improvement to uppercase the first letter of color value
      if (tabValues[i][0] == "color")
            selectedColor = tabValues[i][1].charAt(0).toUpperCase() + tabValues[i][1].slice(1);
}

// if selected color is not false, change the content of corresponding html tag
// in this example the html tag had an ID = theColorname
if (selectedColor)
      $('#theColorname').text(selectedColor);

I'm also have to inform, if you used Prestashop v.1.6.1.0 then you don't have to create and define new variable nb_attr as shown above, because within the product.js file there was an available variable which already define the count number of combinations from the URL  :

var len = tabParams.length;

Click here for working example

[//demo.webindoshop.com/en/tshirts/1-faded-short-sleeves-tshirt.html#/size-s/color-blue]




#2114852 [SOLVED] Add color name from colorPickerClick selection to product page

Posted by gonebdg - webindoshop.com on 05 August 2015 - 05:12 AM

That's it ...

 

Try to add following script underneath js comment   // fill html with values

// define new variable for selected color with value false
var selectedColor = false;

// count number of combinations from the URL
var nb_attr = tabParams.length;

// get the color value from the loop
for (var i=0; i<nb_attr i++)
{
      if (tabValues[i][1] == "color")
            selectedColor = tabValues[i][2];
}

// if selected color is not false, change the content of corresponding html tag
// in this example the html tag had an ID = theColorname
if (selectedColor )
      $('#theColorname').text(selectedColor);

If you visit the product page with URL //domain.com/product.html#/1-color-blue/

Then the selected_color var should have a value blue

and the html tag will filled with a text blue

<span id="theColorname">blue</span>



#2110439 Remove Delivery and Invoice Address fields in the Guest Checkout (PS 1.6)

Posted by gonebdg - webindoshop.com on 30 July 2015 - 12:03 PM

Before we begin, I would like to inform if the following variables is associated with customer object (only certain variables mentioned here):

id_gender (social title), firstname, lastname, email, birthday (date of birth)

 

Whereas "address", "zip/postal code", "city", "country", "state", "phone", "mobile phone" are variables associated with address object.

 

Since you only need : first and last name, email and mobile number, then you only need to activate one country (your country of course).

 

Conditions :

Prestashop v.1.6.1.0

Order process type > One-page Checkout

Guest Checkout > Enabled

 

1st, change the address format, go to : B.O > Localization > Countries
Pick your country and change the address format, click the "Edit" menu available on the right.
Scroll down to the "Address format" field option
Remove all default values available on "Address format" but keep the "phone_mobile"
Set all of the following configuration options to "NO" : "Does it need Zip/postal code?", "Contains states", "Do you need a tax identification number?"
Set the "Zip/postal code format" empty/blank
Save the changes.

 

2nd, modify theme file order-opc-new-account.tpl to remove (hide) the unnecessary fields.

Add new class "hide" into the corresponding div tag which wrapping the unecessary fields.

For example if we want to hide "Social title", then find <label>{l s='Social title'}</label> and add new class "hide" to the div wrapper (it's above the label html tag).

<div class="hide required clearfix gender-line">
      <label>{l s='Social title'}</label>
      {* Rest of smarty code here *}
</div>

Do the same procedure for the unnecessary fields.
Then try to place a test order on your shop and checkout with "Instant Checkout" / "Guest Checkout", the unnecessary fields should be hidden right now.

 

.

 

... Next 3rd, create dummy address by defining default field value




#2106820 Jquery is not working

Posted by gonebdg - webindoshop.com on 27 July 2015 - 06:34 AM

You don't have to use another jquery library from another source like from google hosted libraries because PrestaShop already load the necessary jquery library (built-in).
For example since PrestaShop v.1.6.x the jquery library v.1.11.0 already built-in and automatically loaded, but in PrestaShop v.1.5.6 the jquery library version is v.1.7.2

Make sure you don't load another jquery library in your PrestaShop, or it will causing a conflict and make more trouble for you.
Unless it's really required and you know what you're doing.

I guess my previous question is not clear and making you confuse ...
What i need to know is what jquery plugin that you use for carousel ?
There are a lot of jquery carousel plugin out there, and some jquery carousel plugin might only work with certain jquery library version (compatibility), so make sure about that prior to use it.

Commonly jquery carousel plugin will need you to setup the necessary jquery statement within your "jquery document ready" which refer to html element ID, for example :

pay attention to div id selector

$(document).ready(function() {
      $('#my_carousel').myJqueryPluginName();
});

Then your html markup might have something like this :

<div id="my_carousel" class="my-jquery-plugin-name">
      <div class="carousel_items">
            <img src="image-01.jpg">
            <span>descriptions-01</span>
      </div>
      <div class="carousel_items">
            <img src="image-02.jpg">
            <span>descriptions-02</span>
      </div>
      <!-- other carousel items here -->
</div>

Then to find out what its wrong with your JS carousel, you should check the error log which can be viewed through your browser console log as a said on my previous post above.

 

AND please use Code < > instead Quote when you write some programing code (html, php, js, smarty, etc) on your post




#2106411 Opacity cms block, only background

Posted by gonebdg - webindoshop.com on 26 July 2015 - 10:47 AM

Your css code is wrong, you can't do like that.
If you want opacity just for the background instead all elements inside block ID #cmsinfo_block, then you can use rgba (but won't work on old browser)

#cmsinfo_block {
  overflow: hidden;
  background: rgba(12, 139, 212, 0.5);
  min-height: 344px;
  height: 344px;
  padding-right: 29px;
  padding-left: 29px;
}

But if you want opacity for all elements inside block ID #cmsinfo_block, then remove the brackets { } within your modified css code.

#cmsinfo_block {
  overflow: hidden;
  background: #0c8bd4;
  opacity: 0.50;
  min-height: 344px;
  height: 344px;
  padding-right: 29px;
  padding-left: 29px;
}



#2090272 Free BLOG module untuk Prestashop

Posted by gonebdg - webindoshop.com on 07 July 2015 - 06:09 AM

Free Module Blog untuk PrestaShop :

https://www.prestash...op-blog-module/

https://www.prestash...le/#entry669210

 

Topik thread ini silahkan anda ganti yg lebih relevan




#1911521 [Ps 1.6] - Module development - Controllers and views

Posted by gonebdg - webindoshop.com on 30 December 2014 - 01:46 PM

I guess you should override parent method renderList()

 

something like this :

/* 
** Override renderList() method to show order state name instead ID
** @see public function renderList() ; /classes/controller/AdminController.php
** In here "status" is a field which hold id_order_state
*/
public function renderList()
{
     if (!($this->fields_list && is_array($this->fields_list)))
         return false;
     $this->getList($this->context->language->id);

     // Start Modification
     $nb_list = count($this->_list);        
     for($i=0;$i <= $nb_list;$i++)
     {
         if (isset($this->_list[$i]['status']) && $status = $this->_list[$i]['status'])
         {
             // instantiate object OrderState
             $order_state = new OrderState((int)$status, (int)$this->context->language->id);
             // Show OrderState name instead ID
             $this->_list[$i]['status'] = $order_state->name;
         }        
     }
     // End Modification

     // instantiate object HelperList
     $helper = new HelperList();
        
     // Empty list is ok
     if (!is_array($this->_list))
     {
         $this->displayWarning($this->l('Bad SQL query', 'Helper').'<br />'.htmlspecialchars($this->_list_error));
         return false;
     }

     $this->setHelperDisplay($helper);
     $helper->tpl_vars = $this->tpl_list_vars;
     $helper->tpl_delete_link_vars = $this->tpl_delete_link_vars;

     // For compatibility reasons, we have to check standard actions in class attributes
     foreach ($this->actions_available as $action)
     {
         if (!in_array($action, $this->actions) && isset($this->$action) && $this->$action)
             $this->actions[] = $action;
     }

     $list = $helper->generateList($this->_list, $this->fields_list);

     return $list;
}

NOTE:

This is just an example and untested, then maybe this example won't working as expected, but i hope this example can help you to figuring out how to achieve your purpose.

AND don't forget to change your field_list "status" type from "int" to "text"




#1909738 [Ps 1.6] - Module development - Controllers and views

Posted by gonebdg - webindoshop.com on 28 December 2014 - 07:45 AM

Sure you can.

You can create object methods to achieve that
But the variables which will be saved in separate DB table can not be added within the object property $definition.
Object property $definition is to define variables belong to the specified DB table or to define variables related to multilingual, multishop or object associations.

 

I'm not sure if i'm understand your second question.

If you need to set a value for orderId, you just have to add it on your form or you can automatically retrieving the value with the existing object.




#1904378 [Ps 1.6] - Module development - Controllers and views

Posted by gonebdg - webindoshop.com on 20 December 2014 - 08:21 AM

Usually i create my Admin module controller and determine the required variables in class constructor, also create custom classes file for the data which will be processed (add/edit/delete) by this controller.
So the data will be treated as an object, because that was the reason why I use PHP OOP and MVC pattern (Prestashop)

 

example :

<?php
/*
** My Admin Module Controller
** Module name : mymodulename (as defined on module file, $this->name)
** With this controller I will be able to Add/Edit/Delete data (object) that i want
** Controller Class name doesn't have to use or same as the module name
** In here the class name is Admin + Name + Controller
** "Name" will be used as directory name where the necessary template helper file placed
** e.g: view.tpl
** ..\modules\mymodulename\views\templates\admin\name\helpers\view\view.tpl
*/

class AdminNameController extends ModuleAdminController
{
	public function __construct()
	{
		$this->bootstrap = true;
		$this->module = 'mymodulename'; // valid module name
		$this->table = 'db_table_name'; // DB table name where your object data stored
		$this->className = 'MyObjectClassName'; // The class name of my object
		$this->lang = false;
		$this->explicitSelect = true;
		$this->allow_export = true;
		$this->delete = true;
		$this->context = Context::getContext();
		$this->orderBy = 'id_object'; // DB column field which hold my object ID
		$this->_orderWay = 'DESC';
		$this->fields_list = $this->fieldList();
		$this->shopLinkType = 'shop';
		$this->actions = array('view', 'edit', 'delete');
		$this->bulk_actions = array(
			'delete' => array(
				'text' => $this->l('Delete selected'),
				'icon' => 'icon-trash',
				'confirm' => $this->l('Delete selected object?')
			)
		);

		parent::__construct();
	}

        public function fieldList()
        {
            // determine object fields in here. it will be processed by renderList() method
            // Note: fieldList can also determined directly on class constructor

            return $fields_list;
        }

        /* Function used to render the list to display for this controller */
        public function renderList()
        {
            // No need to use/override this method if not necessary

            return $list;
        }

        /* Function used to render the view page */
        public function renderView()
        {
            // form to add/edit my object are dermined here

            return parent::renderForm();
        }

        /* Function used to render the form for this controller */
        public function renderForm()
        {
            // form to add/edit my object are dermined here

            return parent::renderForm();
        }
}

If everytings is ok, and i've created the renderForm() method for my controller, the "Add new" action menu will automatically available. On the top right of the data list table (rendered by my controller) there will be an action menu icon [+] which created automatically by Prestashop system.

 

The parent classes AdminController.php will handle the process with processAdd() method

 

If i click this icon menu, i can create new object value without having to bother writing my php code on my controller.

Unless there is customizations needed or special circumstances which require me to extend processAdd() method.

 

I suggest you to take a look deep inside Prestashop classes controller files :
AdminModuleController.php and AdminController.php
and then start to create your Admin Module Controller file based on the available Prestashop Admin Controller.




#1904020 [Ps 1.6] - Module development - Controllers and views

Posted by gonebdg - webindoshop.com on 19 December 2014 - 06:03 PM

For action = edit, you need to define renderForm() method on your controller

for example :

public function renderForm()
{
    // make sure object is loaded
    if (!($obj = $this->loadObject(true)))
        return;

    $this->fields_form = array(
        // array fields for the form, similiar with array on your renderList()
        // for reference, you can see the available Prestashop AdminController
        // e.g : ...\controllers\admin\AdminCustomersController.php
    );

    // then ... let the parent controller class handle it (update object)
    return parent::renderForm();
}



#1901063 extra field to ps_product_attribute

Posted by gonebdg - webindoshop.com on 16 December 2014 - 08:17 PM

You already on the right track :)

 

But the smarty var {$product->attrib_stukprijs} is incorrect, because attrib_stukprijs is a properties of product combination object.

So if you do debugging, for example on ProductController.php :

$id_product_attribute = 1;
$combination = New Combination($id_product_attribute);
// print object combination
p($combination->attrib_stukprijs);

.

OR do debugging like this on your theme file product.tpl

.

<pre>
{$combinations|@print_r:1}
</pre>

.

Then You will see it ...

 

Therefore you should modify your theme file product.tpl to add a html wrapper to display this variable value on select/update product combination

For example :

<p id="attrib_stukprijs" style="display: none;">
      <span></span>
</p>

And then modify product.js

In here i'm giving you an example to add JS script inside function updatePrice()

function updatePrice()
{
    // Original JS script goes here
    // and here ...
    // and here ... ... ...

    // Start our modification
    // Make sure the selected combination have a variable value attrib_stukprijs
    if (combination.attrib_stukprijs)
    {
        // Show the html paragraph which will wrap this var
        $('#attrib_stukprijs').show();

        // Display the value of this var inside the html wrapper
        $('#attrib_stukprijs span').text(combination.attrib_stukprijs);
    }
}

Finnally if you or your customer select/update product combination, then this variable attrib_stukprijs will be displayed






Cookies help us deliver our services. By using our services, you agree to use our cookies.     Learn more