Home |  MySQL Buzz |  FAQ |  Feeds |  Submit your blog feed |  Feedback |  Archive |  Aggregate feed RSS 2.0 English Deutsch Español Français Italiano 日本語 Русский Português 中文
Showing entries 1 to 2

Displaying posts with tag: PrestaShop (reset)

[PrestaShop] Carrier selection by postal code
+0 Vote Up -0Vote Down

To select the carrier / delivery method in PrestaShop by the postal code of the delivery address, create a file Address.php in /override/classes with this content:

<?php
class Address extends AddressCore
{
    protected static function getPostcodeByAddress($id_address) {
        $row = Db::getInstance()->getRow('
            SELECT `postcode`
            FROM '._DB_PREFIX_.'address a
            WHERE a.`id_address` = '.(int)($id_address));
        return $row['postcode'];
    }

    public static function getZoneById($id_address)
    {
        $postcode = self::getPostcodeByAddress($id_address);
        if (in_array($postcode, Array(1050)))
            return 1;
        elseif (in_array($postcode, Array(2000)))
            return 10;
        return 0;
    }
}

In this example, postal code 1050 is assigned to the carrier with ID 1 and postal

  [Read more...]
[PrestaShop] Converting .htaccess to nginx include files
+0 Vote Up -0Vote Down

If you use PrestaShop and nginx, you may find this script to convert PrestaShop’s .htaccess rules into an nginx rule file useful:

#!/usr/local/bin/perl
print <<EOF;
fastcgi_buffers           16 128k;
fastcgi_busy_buffers_size 128k;
fastcgi_buffer_size       128k;
client_body_buffer_size   128k;
EOF
while (<>) {
    if (/^RewriteRule \^(.*) \[L\]$/) { print "rewrite ^/$1? break;\n"; }
    if (/^RewriteRule \^(.*) \[QSA,L\]$/) { print "rewrite ^/$1 break;\n"; }
    if (/^ErrorDocument (\d+) (.*)$/) { print "error_page $1 = $2;\n"; }
}

Save as convert-htaccess.pl and run with ./convert-htaccess.pl <.htaccess >.htaccess.nginx. Then don’t forget to include .htaccess.nginx into your nginx site configuration and reload nginx.

If you have multiple languages or an other configuration that includes { brackets }, you may

  [Read more...]
Showing entries 1 to 2

Planet MySQL © 1995, 2014, Oracle Corporation and/or its affiliates   Legal Policies | Your Privacy Rights | Terms of Use

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.