On avance sur CadeauBienvenue
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd">
|
||||
|
||||
<services>
|
||||
<service id="customer.creation.event" class="CadeauBienvenue\EventListeners\NewCustomerListener" scope="request">
|
||||
<service id="customer.creation.event" class="CadeauBienvenue\EventListeners\NewCustomerListener">
|
||||
<argument type="service" id="request"/>
|
||||
<argument type="service" id="mailer"/>
|
||||
<argument type="service" id="event_dispatcher"/>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<title>Generate a personal coupon for every new customer</title>
|
||||
</descriptive>
|
||||
<descriptive locale="fr_FR">
|
||||
<title>Généré un code promotion personnel pour chaque nouveau client</title>
|
||||
<title>Génère un code promotion personnel pour chaque nouveau client</title>
|
||||
</descriptive>
|
||||
<languages>
|
||||
<language>en_US</language>
|
||||
|
||||
@@ -3,10 +3,8 @@
|
||||
namespace CadeauBienvenue\EventListeners;
|
||||
|
||||
use CadeauBienvenue\CadeauBienvenue;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent;
|
||||
use Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
@@ -50,7 +48,7 @@ class NewCustomerListener implements EventSubscriberInterface
|
||||
{
|
||||
$customer = $event->getCustomer();
|
||||
|
||||
$couponCode = substr(str_shuffle(md5(time())), 0, 12);
|
||||
$couponCode = substr(str_shuffle(md5(time())), 0, 14);
|
||||
$discountAmount = ConfigQuery::create()->filterByName(CadeauBienvenue::VARIABLE_MONTANT_CODE_PROMO)->findOne()->getValue();
|
||||
$couponServiceId = 'thelia.coupon.type.remove_x_amount';
|
||||
$effects = [ 'amount' => $discountAmount];
|
||||
@@ -61,8 +59,8 @@ class NewCustomerListener implements EventSubscriberInterface
|
||||
$couponServiceId, // $serviceId
|
||||
'Offre de bienvenue', // $title
|
||||
$effects, // $effects
|
||||
'', // $shortDescription
|
||||
sprintf('Offre de bienvenue pour %s %s',$customer->getFirstname(), $customer->getLastname()), // $description
|
||||
'Code promotion pour un nouveau client', // $shortDescription
|
||||
sprintf('Code promo de bienvenue pour le client : %s %s (%d)',$customer->getFirstname(), $customer->getLastname(), $customer->getId()), // $description
|
||||
true, // $isEnabled
|
||||
$dateExpiration, // $expirationDate
|
||||
false, // $isAvailableOnSpecialOffers
|
||||
@@ -76,6 +74,7 @@ class NewCustomerListener implements EventSubscriberInterface
|
||||
);
|
||||
$this->dispatcher->dispatch(TheliaEvents::COUPON_CREATE, $couponEvent);
|
||||
|
||||
|
||||
// Envoyer le mail au client
|
||||
$this->mailer->sendEmailToCustomer(
|
||||
CadeauBienvenue::MESSAGE_MAIL_CLIENT,
|
||||
@@ -87,7 +86,5 @@ class NewCustomerListener implements EventSubscriberInterface
|
||||
'code_promo' => $couponCode
|
||||
]
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
{extends file="email-layout.tpl"}
|
||||
|
||||
{* Do not provide a "Open in browser" link *}
|
||||
{block name="browser"}{/block}
|
||||
{* No pre-header *}
|
||||
{block name="pre-header"}{/block}
|
||||
|
||||
{* Subject *}
|
||||
{block name="email-subject"}Bienvenue chez AuxBieauxLegumes.fr - Code promo{/block}
|
||||
|
||||
{* Title *}
|
||||
{block name="email-title"}Bienvenue chez AuxBieauxLegumes.fr - Code promo{/block}
|
||||
|
||||
{* Content *}
|
||||
{block name="email-content"}
|
||||
{loop type="customer" name="client" current="false" id=$customer_id}<p>Bonjour {$FIRSTNAME} {$LASTNAME},</p>{/loop}
|
||||
|
||||
<p>Pour fêter votre arrivée sur notre site {$nom_site}, nous vous offrons un bon de réduction d'une valeur de {$montant}€, utilisable dès votre prochain achat !
|
||||
Ce bon est valable jusqu'au {format_date date={$date_validite} output="date"}.</p>
|
||||
|
||||
<p>Rendez-vous très bientôt sur <a href="{url path='/'}">{url path="/"}</a></p>
|
||||
|
||||
<p>Très cordialement,</p>
|
||||
<p>{config key="store_name"}.</p>
|
||||
{/block}
|
||||
@@ -1,23 +0,0 @@
|
||||
{extends file="email-layout.tpl"}
|
||||
|
||||
{* Do not provide a "Open in browser" link *}
|
||||
{block name="browser"}{/block}
|
||||
{* No pre-header *}
|
||||
{block name="pre-header"}{/block}
|
||||
|
||||
{* Subject *}
|
||||
{block name="email-subject"}Bienvenue chez AuxBieauxLegumes.fr - Code promo{/block}
|
||||
|
||||
{* Title *}
|
||||
{block name="email-title"}Bienvenue chez AuxBieauxLegumes.fr - Code promo{/block}
|
||||
|
||||
{* Content *}
|
||||
{block name="email-content"}
|
||||
{loop type="customer" name="client" current="false" id=$customer_id}<p>Bonjour {$FIRSTNAME} {$LASTNAME},</p>{/loop}
|
||||
|
||||
<p>Pour fêter votre arrivée sur notre site {$nom_site}, nous vous offrons un bon de réduction d'une valeur de {$montant}€, utilisable dès votre prochain achat !
|
||||
Ce bon est valable jusqu'au {format_date date={$date_validite} output="date"}.</p>
|
||||
<p>Rendez-vous très bientôt sur <a href="{url path='/'}">{url path="/"}</a></p>
|
||||
<p>Très cordialement,</p>
|
||||
<p>{config key="store_name"}.</p>
|
||||
{/block}
|
||||
@@ -146,10 +146,10 @@
|
||||
</hook>
|
||||
|
||||
<!-- Additional fields for the register form -->
|
||||
<!--<hook id="customer.family.register.form" class="CustomerFamily\Hook\CustomerFamilyRegisterFormHook">
|
||||
<hook id="customer.family.register.form" class="CustomerFamily\Hook\CustomerFamilyRegisterFormHook">
|
||||
<tag name="hook.event_listener" event="register.form-bottom" type="front" method="onRegisterFormBottom"/>
|
||||
<tag name="hook.event_listener" event="register.after-javascript-include" type="front" method="onRegisterAfterJSInclude"/>
|
||||
</hook>-->
|
||||
</hook>
|
||||
|
||||
<!-- Showing customer family information -->
|
||||
<hook id="customer.family.account.display" class="CustomerFamily\Hook\CustomerFamilyAccountDisplayHook">
|
||||
|
||||
@@ -129,7 +129,7 @@ class CustomerFamilyFormListener extends BaseAction implements EventSubscriberIn
|
||||
self::CUSTOMER_FAMILY_VAT_FIELD_NAME,
|
||||
'text',
|
||||
array(
|
||||
'required' => true,
|
||||
'required' => false,
|
||||
'empty_data' => false,
|
||||
'label' => self::trans('Vat'),
|
||||
'label_attr' => array(
|
||||
|
||||
@@ -89,7 +89,7 @@ class CustomerCustomerFamilyForm extends BaseForm
|
||||
'siret',
|
||||
'text',
|
||||
array(
|
||||
'required' => false,
|
||||
'required' => true,
|
||||
'empty_data' => false,
|
||||
'label' => Translator::getInstance()->trans(
|
||||
'Siret number',
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'By checking this check box this module will use the product price of Thelia instead of the the purchase price of CustomerFamily' => 'En cochant cette case, le module va utiliser le prix de vente du produit plutôt que son prix d\'achat.',
|
||||
'Code' => 'Code',
|
||||
'Customer' => 'Client',
|
||||
'Customer family' => 'Famille clients',
|
||||
'Customer family' => 'Vous êtes un ?',
|
||||
'Customer family was created successfully' => 'La famille a été créée avec succès',
|
||||
'Customer family was deleted successfully' => 'La famille a été supprimée avec succès',
|
||||
'Customer family was updated successfully' => 'La famille a été modifiée avec succès',
|
||||
@@ -16,5 +17,6 @@ return array(
|
||||
'Siret number' => 'Numéro de SIRET',
|
||||
'This field can\'t be empty' => 'Ce champs ne peut pas être vide',
|
||||
'Title' => 'Nom',
|
||||
'Use the product price' => 'Utiliser le prix de vente',
|
||||
'Vat' => 'TVA intracommunautaire',
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'Customer family' => 'Famille de client',
|
||||
'Customer family' => 'Informations professionnelles',
|
||||
'Placeholder SIRET' => 'SIRET',
|
||||
'Placeholder V.A.T.' => 'Taxe sur la Valeur Ajoutée',
|
||||
'Select customer family' => 'Sélectionnez un type de compte',
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12 general-block-decorator">
|
||||
<div class="row">
|
||||
<div class="col-md-12 title title-without-tabs">{intl l="Family of this customer" d="customerfamily"}</div>
|
||||
<div class="col-md-12 title title-without-tabs">{intl l="Family of this customer" d="customerfamily.bo.default"}</div>
|
||||
<div class="col-md-12">
|
||||
<div class="col-md-12">
|
||||
{form name="customer.customer.family.form"}
|
||||
@@ -39,7 +39,7 @@
|
||||
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
|
||||
|
||||
<div class="control-input">
|
||||
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" maxlength="255" placeholder="{intl l="Placeholder siret"}" value="{$_siret_}"{if $required} aria-required="true"{/if}{if !isset($error_focus) && $error} autofocus{/if}>
|
||||
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" maxlength="255" placeholder="{intl l='Placeholder siret'}" value="{$_siret_}"{if $required} aria-required="true"{/if}{if !isset($error_focus) && $error} autofocus{/if}>
|
||||
{if $error }
|
||||
<span class="help-block">{$message}</span>
|
||||
{assign var="error_focus" value="true"}
|
||||
@@ -50,10 +50,10 @@
|
||||
|
||||
{form_field form=$form field="vat"}
|
||||
<div class="form-group group-email {if $error}has-error{/if}">
|
||||
<label class="control-label" for="{$label_attr.for}">{$label} <span class="required">*</span></label>
|
||||
<label class="control-label" for="{$label_attr.for}">{$label}</label>
|
||||
|
||||
<div class="control-input">
|
||||
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" maxlength="255" placeholder="{intl l="Placeholder vat"}" value="{$_vat_}"{if $required} aria-required="true"{/if}{if !isset($error_focus) && $error} autofocus{/if}>
|
||||
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" maxlength="255" placeholder="{intl l='Placeholder vat'}" value="{$_vat_}"{if $required} aria-required="true"{/if}{if !isset($error_focus) && $error} autofocus{/if}>
|
||||
{if $error }
|
||||
<span class="help-block">{$message}</span>
|
||||
{assign var="error_focus" value="true"}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
{default_translation_domain domain=$messageDomain}
|
||||
{loop type="customer_customer_family" name="customer_customer_family" customer_id={$customerId} }
|
||||
<div id="customer-customer-family-{$CUSTOMER_ID}-{$CUSTOMER_FAMILY_ID}">
|
||||
{loop type="customer_family" name="customer_family" id={$CUSTOMER_FAMILY_ID} }
|
||||
<table class="table" role="presentation" summary="{$title}">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>{intl l='Customer family'}</th>
|
||||
<td>{$TITLE_CUSTOMER_FAMILY}</td>
|
||||
</tr>
|
||||
{if $CODE != $particular}
|
||||
{* The Customer should have a SIRET and a VAT. Display them. *}
|
||||
<tr>
|
||||
<th>{intl l='Siret number'}</th>
|
||||
<td>{$SIRET}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{intl l='Vat'}</th>
|
||||
<td>{$VAT}</td>
|
||||
</tr>
|
||||
{/if}
|
||||
</tbody>
|
||||
</table>
|
||||
{/loop}
|
||||
</div>
|
||||
{/loop}
|
||||
@@ -0,0 +1,50 @@
|
||||
{default_translation_domain domain=$messageDomain}
|
||||
<fieldset id="register-customer-family" class="panel">
|
||||
<div class="panel-heading">{intl l='Customer family'}</div>
|
||||
<div class="panel-body">
|
||||
{form_field form=$form field='customer_family_code'}
|
||||
<div class="form-group {if $error} has-error{/if}">
|
||||
<label class="control-label" for="{$label_attr.for}">{$label}{if $required} <span class="required">*</span>{/if}</label>
|
||||
<div class="control-input">
|
||||
<select name="{$name}" id="customer_family_code_select" class="form-control"{if $required} aria-required="true" required{/if}{if !isset($error_focus) && $error} autofocus{/if}>
|
||||
<option value="" data-code="none"{if {$value} eq '' } selected="selected"{/if}>-- {intl l="Select customer family"} --</option>
|
||||
{loop type="customer_family" name="customer_family"}
|
||||
<option value="{$CODE}" data-code="{$CODE}"{if {$value} eq {$CODE} } selected="selected"{/if}>{$TITLE_CUSTOMER_FAMILY}</option>
|
||||
{/loop}
|
||||
</select>
|
||||
{if $error }
|
||||
<span class="help-block">{$message}</span>
|
||||
{assign var="error_focus" value="true"}
|
||||
{/if}
|
||||
</div>
|
||||
</div><!--/.form-group-->
|
||||
{/form_field}
|
||||
{* Additional fields for CustomerCustomerFamily update. Should not be displayed if the customer is a particular one. *}
|
||||
<div id="customer-family-extra-fields">
|
||||
{form_field form=$form field='siret' }
|
||||
<div class="form-group{if $error} has-error{/if}">
|
||||
<label class="control-label" for="{$label_attr.for}">{$label}{if $required} <span class="required">*</span>{/if}</label>
|
||||
<div class="control-input">
|
||||
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" maxlength="255" placeholder="{intl l='Placeholder SIRET'}" value="{$value}" {if $required} aria-required="true" required{/if}{if !isset($error_focus) && $error} autofocus{/if}>
|
||||
{if $error }
|
||||
<span class="help-block">{$message}</span>
|
||||
{assign var="error_focus" value="true"}
|
||||
{/if}
|
||||
</div>
|
||||
</div><!--/.form-group-->
|
||||
{/form_field}
|
||||
{form_field form=$form field='vat' }
|
||||
<div class="form-group{if $error} has-error{/if}">
|
||||
<label class="control-label" for="{$label_attr.for}">{$label}{if $required} <span class="required">*</span>{/if}</label>
|
||||
<div class="control-input">
|
||||
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" maxlength="255" placeholder="{intl l='Placeholder V.A.T.'}" value="{$value}" {if $required} aria-required="true" required{/if}{if !isset($error_focus) && $error} autofocus{/if}>
|
||||
{if $error }
|
||||
<span class="help-block">{$message}</span>
|
||||
{assign var="error_focus" value="true"}
|
||||
{/if}
|
||||
</div>
|
||||
</div><!--/.form-group-->
|
||||
{/form_field}
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
@@ -0,0 +1,16 @@
|
||||
$('#customer_family_code_select').change(customerFamilyShowProFields);
|
||||
|
||||
/* Number for the customer family panel. */
|
||||
$(document).ready(function (e) {
|
||||
$('#number-customer-family').text($('#register-customer-family').prevAll('fieldset').length + 1);
|
||||
customerFamilyShowProFields();
|
||||
});
|
||||
|
||||
/* Hiding professional fields if the customer is not a professional one. */
|
||||
function customerFamilyShowProFields() {
|
||||
var data_code = $('#customer_family_code_select option:selected').attr('data-code');
|
||||
$('#customer-family-extra-fields').css(
|
||||
'display',
|
||||
(data_code === 'particular' || data_code === 'none') ? 'none' : 'block'
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
/* Hiding professional fields if the customer is not a professional one. */
|
||||
function customerFamilyShowProFields() {
|
||||
var data_code = $('#customer_family_code_select option:selected').attr('data-code');
|
||||
$('#customer-family-extra-fields').css(
|
||||
'display',
|
||||
(data_code === 'particular' || data_code === 'none') ? 'none' : 'block'
|
||||
);
|
||||
}
|
||||
|
||||
$('#customer_family_code_select').change(customerFamilyShowProFields);
|
||||
$(document).ready(customerFamilyShowProFields);
|
||||
@@ -0,0 +1,49 @@
|
||||
<fieldset id="register-customer-family" class="panel panel-info">
|
||||
<div class="panel-heading"><span id="number-customer-family"></span>. {intl l='Customer family-Section title' d='customerfamily.fo.custom'}</div>
|
||||
<div class="panel-body">
|
||||
{form_field form=$form field='customer_family_code'}
|
||||
<div class="form-group {if $error} has-error{/if}">
|
||||
<label class="control-label col-sm-3" for="{$label_attr.for}">{$label}{if $required} <span class="required">*</span>{/if}</label>
|
||||
<div class="control-input col-sm-5">
|
||||
<select name="{$name}" id="customer_family_code_select" class="form-control"{if $required} aria-required="true" required{/if}{if !isset($error_focus) && $error} autofocus{/if}>
|
||||
<option value="" data-code="none">-- {intl l="Select customer family"} --</option>
|
||||
{loop type="customer_family" name="customer_family"}
|
||||
<option value="{$CODE}" data-code="{$CODE}" {if $IS_DEFAULT == 1} selected="selected"{/if}>{$TITLE_CUSTOMER_FAMILY}</option>
|
||||
{/loop}
|
||||
</select>
|
||||
{if $error }
|
||||
<span class="help-block">{$message}</span>
|
||||
{assign var="error_focus" value="true"}
|
||||
{/if}
|
||||
</div>
|
||||
</div><!--/.form-group-->
|
||||
{/form_field}
|
||||
{* Additional fields for CustomerCustomerFamily creation. Should not be displayed if the customer is a particular one. *}
|
||||
<div id="customer-family-extra-fields">
|
||||
{form_field form=$form field='siret' }
|
||||
<div class="form-group{if $error} has-error{/if}">
|
||||
<label class="control-label col-sm-3" for="{$label_attr.for}">{$label}{if $required} <span class="required">*</span>{/if}</label>
|
||||
<div class="control-input col-sm-5">
|
||||
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" maxlength="255" placeholder="{intl l='Placeholder SIRET'}" value="{$value}" {if $required} aria-required="true" required{/if}{if !isset($error_focus) && $error} autofocus{/if}>
|
||||
{if $error }
|
||||
<span class="help-block">{$message}</span>
|
||||
{assign var="error_focus" value="true"}
|
||||
{/if}
|
||||
</div>
|
||||
</div><!--/.form-group-->
|
||||
{/form_field}
|
||||
{form_field form=$form field='vat' }
|
||||
<div class="form-group{if $error} has-error{/if}">
|
||||
<label class="control-label col-sm-3" for="{$label_attr.for}">{$label}{if $required} <span class="required">*</span>{/if}</label>
|
||||
<div class="control-input col-sm-5">
|
||||
<input type="text" name="{$name}" id="{$label_attr.for}" class="form-control" maxlength="255" placeholder="{intl l='Placeholder V.A.T.'}" value="{$value}" {if $required} aria-required="true" required{/if}{if !isset($error_focus) && $error} autofocus{/if}>
|
||||
{if $error }
|
||||
<span class="help-block">{$message}</span>
|
||||
{assign var="error_focus" value="true"}
|
||||
{/if}
|
||||
</div>
|
||||
</div><!--/.form-group-->
|
||||
{/form_field}
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
@@ -7,14 +7,14 @@
|
||||
<label class="control-label" for="{$label_attr.for}">{$label}{if $required} <span class="required">*</span>{/if}</label>
|
||||
<div class="control-input">
|
||||
<select name="{$name}" id="customer_family_code_select" class="form-control"{if $required} aria-required="true" required{/if}{if !isset($error_focus) && $error} autofocus{/if}>
|
||||
<option value="" data-code="none"{if "$value" == '' } selected="selected"{/if}>-- {intl l="Select customer family"} --</option>
|
||||
{loop type="customer_family" name="customer_family"}
|
||||
<option value="{$CODE}" data-code="{$CODE}" {if "$value" == "$CODE" } selected="selected"{/if}>{$TITLE_CUSTOMER_FAMILY}</option>
|
||||
{/loop}
|
||||
<option value="" data-code="none"{if "$value" == '' } selected="selected"{/if}>-- {intl l="Select customer family"} --</option>
|
||||
{loop type="customer_family" name="customer_family"}
|
||||
<option value="{$CODE}" data-code="{$CODE}" {if "$value" == "$CODE" } selected="selected"{/if}>{$TITLE_CUSTOMER_FAMILY}</option>
|
||||
{/loop}
|
||||
</select>
|
||||
{if $error }
|
||||
<span class="help-block">{$message}</span>
|
||||
{assign var="error_focus" value="true"}
|
||||
{assign var="error_focus" value="true"}
|
||||
{/if}
|
||||
</div>
|
||||
</div><!--/.form-group-->
|
||||
|
||||
Reference in New Issue
Block a user