COD ¿Qué queremos hacer?

Slides:



Advertisements
Presentaciones similares
Miss Elena Instrucciones para crear una cuenta Cbox Crear una cuenta CBox.
Advertisements

© 2006 XBRL International, All Rights Reservedwww.xbrl.org/Legal Ignacio Hernández-Ros Technology development XBRL International Using XQuery to process.
¿Qué quieres ser? Quiero ser …...
Español 1 el 26 de agosto. Empezar el 26 de agosto Translate: Hi! My name is John. How are you? Whats your name? See you later. Its 5:00 p.m. Whats happening?/Whats.
Daniel Correa Botero. Las capas en azul representan módulos prediseñados que no se deben programar.
SESION 4 PROGRAMACIÓN. Septiembre 2010 SESION 3: OPERADORES 1 Comentarios /* */ // /// La guía de estilo de UA determina que: No se debe escribir comentario.
 1. Why should a person learn Spanish? Give at least 3 reasons in your explanation.  2. What Spanish experiences have you had? (None is not an option.
Taller 5: Trabajo con Plantillas y uso de tecnología Ajax.
Clases abstractas no polimórficas para C++ Universidad de Costa Rica Escuela de Ciencias de la Computación e Informática Agenda.
PL/SQL Francisco Moreno Universidad Nacional.
Programación orientada a objetos
Programación por Capas: Motor de templates, Vista y Controlador Diseño y Construcción de Productos de Software Daniel Correa Botero Jeferson David Ossa.
Time Expression with Hacer Grammar Essential #106.
Miss Elena Instrucciones para crear una cuenta Cbox Crear una cuenta CBox.
Please sign up for your presentation.. ALC 47 ¿Cuáles son las nueve bebidas?
Programación orientada a objetos Capítulo 4 Agrupar objetos.
DELETE THIS SLIDE BEFORE HANDING IN See the rubric for more details Deadlines will not change, no excuses…all projects must be ed
ALC 68 Hoy es martes el 27 de marzo de 2012 Hay 12 preguntas para la bienvenida. If you have not done the bienvenida yet, you need to make a new flash.
Los números Apuntes de vocabulario. treinta treinta y uno.
Instructions for using this template. Remember this is Jeopardy, so where I have written “Answer” this is the prompt the students will see, and where.
2012-BM5A. Unos tips antes de empezar: C# es Case Sensitive (sensible a mayúsculas) Pepe ≠ pepe ≠ pEpE Las asignaciones se hacen con “=” y las comparaciones.
Trabajar con módulosTrabajar con variables públicasCrear procedimientos Pasar argumentos por valor y por referencia Referencia rápida.
CardSpace con Internet Explorer 7.0 CardSpace con Internet Explorer 7.0.
¿Qué es el theming? Es el proceso de generar html y css a partir de los datos de nuestra aplicación. El diseño de una aplicación web hecha con Drupal lo.
Presentation Title Your company name.
Go to cessarsc9.wixsite.com/clasedeespanol Click in this icon to see the presentation.
Control, adquisición y monitoreo con Arduino y Visual Basic .net
EasyChair How to submit a paper Como someter un paper
BASE DE DATOS IUPSM CLASE PRACTICA. PROF. ING. JOSE L GUZMAN H.
O-ue stem changing verbs
Directions to create Jeopardy Game
¡Bienvenidos al español!
Before you start, please download the app
La concordancia de los tiempos (Sequence of tenses)
CONJUGATIONS TOP 10 IRREGULAR VERBS.
Proyecto de vocabulario de la ciudad
Audio Blog Type your name here.
Searching data in Arrays
Voice Activity 1.04: Directions, Grammar, and Examples
Apuntes el 11 de abril PODER (O→UE): to be able, can
PROFESSIONALPOWERPOINT.COM FREE PPT TEMPLATES DOWNLOAD MORE POWERPOINT TEMPLATES FROM PROFESSIONALPOWERPOINT.COM.
Diego Hernández R Pascal Variables Diego Hernández R
PowerPoint Templates provided by PresentationPoint.com Software solutions for digital signage and data driven presentations.
EasyChair How to submit a paper Como someter un paper
Capítulo 1 Mis amigos y yo.
Hola, buenas tardes. ¿Cómo se llama?
Mi ciudad.
Herramientas - Documentación
Integration Services.
Repaso/ Práctica : PREGUNTAS
¿Dónde se juegan los deportes?
La calaca: Una persona famosa Present a historically famous person
CORPORATE BRANDED PRESENTATION TEMPLATE This is a sample text. Insert your desired text here.
Quasimodo: Tienes que hacer parte D de la tarea..
Test: Chapters 5 and 6 Listening Comprehension Practice Click on the speaker icon next to each number and decide if the statement you hear is True, CIERTO.
Asking Questions P. 184 Realidades 1.
Asking Questions P. 184 Realidades 1.
Maps of South America Click to add notes
Preparacion Hoy es jueves el 3 de diciembre
EL TIEMPO PRESENTE ESPAÑOL 2.
Estrategia Munus Camara Oscar Darío Pérez Pineda.
Introduction to CAN. What is CAN and what are some of its features? Serial communication Multi-Master Protocol Compact –Twisted Pair Bus line 1 Megabit.
TITLE. Text Title Text Title Text.
Fundamentals of Web Development - 2 nd Ed.Randy Connolly and Ricardo Hoar Fundamentals of Web DevelopmentRandy Connolly and Ricardo Hoar © 2017 Pearson.
VECTOR: Conjuction of 2 parameters: Module: Quantity, actual value, dimension Direction: “Where is it going to or coming from”
Día 2 –Español 4 NS (HL) y NM (SL)
1. A ¿En qué clase tienes que escribir informes?
This is a sample text. Enter Your text Here Title Goes here This is a sample text. You can replace this text. Enter your text here.
5 Step Concept Template STEPS CONCEPT This is a sample text. Insert your desired text here. Step This is a sample text. Insert your desired.
WELCOME FREE POWERPOINT TEMPLATE DESIGNED BY POWERPOINT SCHOOL about history timelineteamsservicesfollow.
Transcripción de la presentación:

COD ¿Qué queremos hacer? Incluir un porcentaje de recargo para el pago “contra reembolso” Incluir una cantidad fija de recargo para el pago “contra reembolso” Asignar un producto al recargo Opcionalmente: Podemos incluir una variable que nos ponga un techo al importe del carrito para aplicar el recargo

COD ¿Dónde lo hacemos? Clase principal del módulo Controlador para validar el carrito Template (views) 2

COD ¿Dónde lo hacemos? (cont.) Clase principal del módulo - Instalación ( install() ) - Desinstalación ( uninstall())  - Constructor ( __ construct() )  - Formulario de configuración ( getContent () ) - Hook... ( payment ) 3

Instalación ( install() ) COD Instalación ( install() )     public function install()     {         // mod         Configuration::updateValue('COD_PORCENT_FEE', 0);         Configuration::updateValue ('COD_FIXED_FEE', 0);         Configuration::updateValue ('COD_IDPRODUCT_FEE', 0);          // Configuration::updateValue ('COD_MAX_ORDER_AMOUNT', 0);         // end mod         if (!parent::install () OR !$this->registerHook('payment') OR ! $this->registerHook('displayPaymentEU') OR !$this->registerHook('paymentReturn'))             return false;         return true;     }  4

Desinstalación( uninstall() ) COD Desinstalación( uninstall() )     public function uninstall()     {         ¿             if (!Configuration::deleteByName('...') || !Configuration::deleteByName('...') ||! parent::uninstall())                 return false;             return true;         ?      }  5

Constructor ( __ construct() ) COD Constructor ( __ construct() )     public function __ construct()     {         …          if ( ! (int) Configuration::get ( 'COD_IDPRODUCT_FEE' ) )             $this->warning = $this->l('You must assign a product to the fee!!!');      }  6

Formulario de configuración ( getContent () ) COD Formulario de configuración ( getContent  () )     public function getContent()     {         /**          * If values have been submitted in the form, process.          */         if (((bool)Tools ::isSubmit('submitCODModule')) == true) {             $this->postProcess();         }         $this->context->smarty->assign( 'module_dir', $this->_path );         $output = ''; // You can add a tpl file or some html code         return $output.$this->renderForm();     } 7

Procesar el Formulario ( postProcess () ) COD Procesar el Formulario ( postProcess () )     public function postProcess ()     {         $form_values = $this->getConfigFormValues(); foreach (array_keys($form_values) as $key) { Configuration::updateValue($key, Tools::getValue($key)); }     } 8

Formulario de configuración ( getContent () ) COD Formulario de configuración ( getContent  () )     protected function renderForm()     {         $helper = new HelperForm();         $helper->show_toolbar = false;         $helper->table = $this->table;         $helper->module = $this;          $helper->default_form_language = $this->context->language->id;          $helper->allow_employee_form_lang =             Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG', 0);         $helper->identifier = $ this->identifier;         $helper->submit_action = 'submitCODModule';          …     }         9

Formulario de configuración ( getContent () ) COD Formulario de configuración ( getContent  () )     protected function renderForm()     {         ...          $helper->currentIndex = $ this->context->link->getAdminLink('AdminModules', false)              .'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name;          $helper->token = Tools::getAdminTokenLite('AdminModules');           $helper->tpl_vars= array(         'fields_value' => $this->getConfigFormValues(), /* Add values for your inputs */               'languages' =>$this->context->controller->getLanguages(),         'id_language' => $this->context->language->id,          );          return $helper->generateForm(array($ this->getConfigForm()));     }                  10

Formulario de configuración ( getContent () ) COD Formulario de configuración ( getContent  () )     protected function getConfigForm()     {         return array(             'form' => array(                 'legend' => array(                 'title' => $this->l('Settings'),                 'icon' => 'icon-cogs',                 ),                 'input' => array(                       array(           ...                         11

Formulario de configuración ( getContent () ) COD Formulario de configuración ( getContent  () )     protected function getConfigForm()     {         …                 'input' => array(                      array(                          'type' => 'text',                          'prefix' => '<i class="icon icon-cogs"></i>',                          'label' => $this->l('Fee Porcent'),                          'name' => 'COD_PORCENT_FEE',                          'desc' => $this->l('Assign a porcent value to calculate the fee'),                      ),          ...                     12

Formulario de configuración ( getContent () ) COD Formulario de configuración ( getContent  () )     protected function getConfigForm()     {         …                 array(                           'type' => 'text',                           'prefix' => '<i class="icon icon-cogs"></i>',                           'label' => $this->l('Fee Fixed Amount'),                           'name' => 'COD_FIXED_FEE',                           'desc ' => $this->l('Assign a fixed value to calculate the fee'),                       ),          …                       13

Formulario de configuración ( getContent () ) COD Formulario de configuración ( getContent  () )     protected function getConfigForm()     {         …                     array(                            'type' => 'text',                            'prefix' => '<i class="icon icon-cogs"></i>',                            'label' => $this->l('ID Product Fee'),                            'name' => 'COD_IDPRODUCT_FEE',                            'desc' => $this->l('Assign a product to the fee'),                        ),           …            14

Formulario de configuración ( getContent () ) COD Formulario de configuración ( getContent  () )     protected function getConfigForm()     {         …                ),                         'submit' =>array (                       'title' => $this->l('Save'),                    ),                 ),          );         } .../ modules/modulename/views/templates/admin/_configure/helpers/form/form.tpl 15

COD Hook... ( payment ) public function hookPayment($params) {     {         if (!$this->active)             return ;         global $smarty;         // Check if cart has product download         if ($this->hasProductDownload($params['cart']))             return false;         // mod    …                 16

COD Hook... ( payment ) Public function hookPayment($params) { ...     {    ...         // mod         $cod_content = array('fee' => 0, 'porcent_fee' =>0, 'fixed_fee' => 0);          $fee = 0;          if ((int)Configuration::get('COD_IDPRODUCT_FEE') > 0)          {              $cart = $this->context->cart;              $cart_details = $cart->getSummaryDetails(null, true);              $idproduct_fee = (int)Configuration::get('COD_IDPRODUCT_FEE');              $porcent_fee = (float)Configuration::get('COD_PORCENT_FEE');  17

COD Hook... ( payment ) public function hookPayment($params) { ...     {    ...             $fixed_fee = (float)Configuration::get('COD_FIXED_FEE');             $p = new Product($idproduct_fee);               $vat = ($p->getTaxesRate()/100);               $fee = 0;               if($porcent_fee  > 0)               {                   $fee = number_format(( $cart_details['total_price'] * $porcent_fee ) / 100, 2, '.', '' );      ...                 18

COD Hook... ( payment ) public function hookPayment($params) { ...     {     ...                 if ($fixed_fee >0)                    {                       $fee += $fixed_fee ;                   }                }                else if ($fixed_fee >0)                {                    $fee =$fixedfee;               }        ...             19

COD Hook... ( payment ) public function hookPayment($params) { …     {     …           if ((int)Configuration::get('COD_IDPRODUCT_FEE') > 0)            {        ...             $fee = number_format ($fee,2,'.','');             $cod_content['fee'] = $fee;                $cod_content['porcent_fee'] = $porcent_fee;                 $cod_content['fixed_fee'] =  $fixed_fee;         }             // end mod     …  20

COD Hook... ( payment ) public function hookPayment($params) { ...     {     ...         $smarty->assign(array (               'cod_content' => $cod_content, // by cpm                 'this_path' =>             $this->_path , //keep for retro compat                             'this_path_cod' => $this->_path,                  'this_path_ssl' => Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'modules/'.$this->name.'/'              ));              return $this->display(__FILE__, 'payment.tpl');       } 21

Controlador para validar el carrito COD Controlador para validar el carrito Validación:     Debemos cambiar el total del carrito, tambien podemos incluir más información si queremos.     public function initContent()     {         parent::initContent();         $total = floatval($this->calcFee()) + floatval($this->context->cart->getOrderTotal(true, Cart::BOTH));         $this->context->smarty->assign(array(             'total' => $total,             'this_path' => $this->module->getPathUri(), // keep for retro compat             'this_path_cod' => $this->module->getPathUri(),             'this_path_ssl' => Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'modules/'                 .$ this->module->name.'/'         ));         $this->setTemplate('validation.tpl');     } 22

Controlador para validar el carrito COD Controlador para validar el carrito Validación:     Debemos cambiar el total del carrito, tambien podemos incluir más información si queremos. (Cont.)     La función calcFee(), va a ser algo muy parecido a lo que ya hemos utilizado en la clase del módulo public function calcFee()  {      $fee = 0;      if ((int)Configuration::get('COD_IDPRODUCT_FEE') > 0)      {          $cart = $this->context->cart;          $cart_details = $cart->getSummaryDetails(null, true);          $idproduct_fee = (int)Configuration::get('COD_IDPRODUCT_FEE');          $porcent_fee = Configuration::get('COD_PORCENT_FEE');          $fixed_fee = Configuration::get('COD_FIXED_FEE');          $p = new Product($idproduct_fee);          $vat = ($p->getTaxesRate()/100);          if ($porcent_fee > 0)          {              $fee = number_format( ( $cart_details['total_price']  *                  $porcent_fee ) / 100, 2, '.', '' );             ….                 ...                  if ($fixed_fee > 0) ​                 { ​                     $fee += $fixed_fee; ​                 } ​             } ​             else if ($fixed_fee > 0) ​             { ​             $fee = $fixedfee; ​         $fee=number_format($fee,2,'.',''); ​         } ​         return $fee; ​ }​ 23

Controlador para validar el carrito COD Controlador para validar el carrito PostProcess:     Debemos incluir el producto para el recargo, justo antes de pasar el carrito a pedido.     public function postProcess()    {        ...         if (Tools::getValue('confirm'))         {             $customer = new Customer((int)$this->context->cart->id_customer);             $fee= floatval($this->calcFee());             $idproduct_fee = (int)Configuration::get('COD_IDPRODUCT_FEE');             $total = $fee + floatval($this->context->cart->getOrderTotal(true, Cart::BOTH));orig: $total = $this->context->cart->getOrderTotal(true, Cart::BOTH);             $p=new Product($idproduct_fee);             $iva=1+($p->getTaxesRate()/100);             $p->price=number_format($fee/$iva,2,'.','');             $p->updateWs();             $cart->updateQty(1,$idproduct_fee);          $cart->getPackageList(true);          $this->module->validateOrder((int)$this->context->cart->id, Configuration::get('PS_OS_PREPARATION'), $total, $this->module->displayName, null,                  array(), null, false, $customer->secure_key);            ….             } 24

COD Podemos ampliar nuestro módulo y mejorarlo - Selección/creación del produccto para recargo                                                                             $p = new Product;                                                                             $p->name = $name;                                                                             $p->id_category_default = $cats[0]; *                                                                             $p->category = $cats[0]; *                                                                             $p->id_tax_rules_group = 0;                                                                             $p->available_for_order = 1;                                                                             $p->visibility = 'both';                                                                             $p->active =0;  - Comprobar que tenemos un producto para recargo y que el producto existe                                                                             if ( $p = new Product ( $ id ) )  - Comprobar el carrito, o comprobar que el recargo es positivo( > 0)                                                                              if ( isnull ( $this->context->cart ) )                                                                                  $this->context->cart=new Cart($context->cookie->id_cart); 25