PrestaShop

PrestaShop::Aggiungere campo contatti extra

Fare rifermento a questo articolo : http://nemops.com/adding-new-fields-to-prestashop-contact-form/#.VY1AaRPtlHw

{theme}/contact-form.tpl

    <label for="extrafield">{l s='Extra field'}</label>
    {if isset($customerThread.extrafield)}
        <input type="text" id="extrafield" name="extrafield" value="{$customerThread.extrafield|escape:'htmlall':'UTF-8'}" readonly="readonly" />
    {else}
        <input type="text" id="extrafield" name="extrafield" value="" />
    {/if}

Creare ovverride: /override/class/CustomerThread.php

class CustomerThread extends CustomerThreadCore
{
    public $extrafield;
 
    public static $definition = array(
        'table' => 'customer_thread',
        'primary' => 'id_customer_thread',
        'fields' => array(
            'id_lang' =>     array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
            'id_contact' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
            'id_shop' =>     array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
            'id_customer' =>array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
            'id_order' =>    array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
            'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
            'email' =>       array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'size' => 254),
            'token' =>       array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true),
            'status' =>  array('type' => self::TYPE_STRING),
            'date_add' =>    array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
            'date_upd' =>    array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
            'extrafield' =>  array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),
        ),
    );
 
 
}

Inserire un campo nella tabelle ps_customer_thread

PrestaShop

ModaScrap::ordine minimo per gruppo

File: /override/controller/front/OrderController

Ovverride della funzione init, questa modifica permette di impostare un minimo prezzo d’acquisto per effettuare la validazione di un’ordine per un gruppo

		// Check minimal amount
		$currency = Currency::getCurrency((int)$this->context->cart->id_currency);

		$orderTotal = $this->context->cart->getOrderTotal();
		$customer = new Customer((int)($this->context->customer->id));
		$Cgroups = $customer->getGroups();
			
		$minimal_purchase = Tools::convertPrice((float)Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
		if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimal_purchase && $this->step > 0)
		{
			$this->step = 0;
			$this->errors[] = sprintf(
				Tools::displayError('A minimum purchase total of %1s (tax excl.) is required to validate your order, current purchase total is %2s (tax excl.).'),
				Tools::displayPrice($minimal_purchase, $currency), Tools::displayPrice($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS), $currency)
			);
		}
		
	if ($Cgroups[0]==4)
			$minimal_purchase = 150;
			
			if ($Cgroups[0]==4 &&  $this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimal_purchase && $this->step > 0)
		{
			$this->step = 0;
			$this->errors[] = sprintf(
				Tools::displayError('A minimum purchase total of %1s (tax excl.) is required to validate your order, current purchase total is %2s (tax excl.).'),
				Tools::displayPrice($minimal_purchase, $currency), Tools::displayPrice($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS), $currency)
			);
		}

 

 

PrestaShop

PrestaShop::Validazione codice fiscale

Validazione Codice fiscale

Modificare {root}/js/validate.js la funzione validate_isDniLite

function validate_isDniLite(s)
{
// 	var reg = /^[0-9a-z-.]{1,16}$/i;
	var reg = /^[A-Z]{6}\d{2}[A-Z]\d{2}[A-Z]\d{3}[A-Z]$/;
	return reg.test(s);
}

 

Percorso: /theme/{nome_tema}/address.tpl

function controllaCF() {
    var p = validate_isDniLite($("#dni").val());
 //    console.log(p);
     if (p == false)	{
	    $("#requiredField").append('<div class="module_error alert alert-danger" id="errorField" style="margin-top:15px;"><button type="button" class="close" data-dismiss="alert">×</button>ERRORE: Il codice fiscale inserito non è valido.</div>');
   $("#errorField").delay(5000).fadeOut(1500);

setTimeout(function() {
  $('#errorField').remove();
}, 7500);     

return false;
}
     
};


$( "#add_address" ).submit(function( event ) {

var checkValidCF = controllaCF();

if (checkValidCF == false){

  event.preventDefault();
  } else {
	  $( "#add_address" ).submit();
  }
});