php - Override function and skip part of the original funtion -


my problem follows. want create override existing method , disable or skip part of code original 1 being executed.

inside class extends abstract class, have added same method. can't create new method solve problem, because method different on multiple versions of specific cms system.

the part want disable or skip creating override, same in of different versions though.

i went through php manual , found pecl apd function override_function.

pecl can't used though, because not using plugin i'm trying create, has pecl extention installed php.

this have far:

public function validateorder($id_cart, $id_order_state, $amount_paid, $payment_method = 'unknown',         $message = null, $extra_vars = array(), $currency_special = null, $dont_touch_amount = false,         $secure_key = false, shop $shop = null)     {  //this part has disabled if (validate::isemail($this->context->customer->email)) {                             mail::send(                                 (int)$order->id_lang,                                 'order_conf',                                 mail::l('order confirmation', (int)$order->id_lang),                                 $data,                                 $this->context->customer->email,                                 $this->context->customer->firstname.' '.$this->context->customer->lastname,                                 null,                                 null,                                 $file_attachement,                                 null, _ps_mail_dir_, false, (int)$order->id_shop                             );           }          parent::validateorder(             $id_cart,             $id_order_state,             $amount_paid,             $payment_method,             $message,             $extra_vars,             $currency_special,             $dont_touch_amount,             $secure_key,             $shop         );      }  

underneath find last part original method:

                    $data = array(                     '{firstname}' => $this->context->customer->firstname,                     '{lastname}' => $this->context->customer->lastname,                     '{email}' => $this->context->customer->email,                     '{delivery_block_txt}' => $this->_getformatedaddress($delivery, "\n"),                     '{invoice_block_txt}' => $this->_getformatedaddress($invoice, "\n"),                     '{delivery_block_html}' => $this->_getformatedaddress($delivery, '<br />', array(                         'firstname'    => '<span style="font-weight:bold;">%s</span>',                         'lastname'    => '<span style="font-weight:bold;">%s</span>'                     )),                     '{invoice_block_html}' => $this->_getformatedaddress($invoice, '<br />', array(                             'firstname'    => '<span style="font-weight:bold;">%s</span>',                             'lastname'    => '<span style="font-weight:bold;">%s</span>'                     )),                     '{delivery_company}' => $delivery->company,                     '{delivery_firstname}' => $delivery->firstname,                     '{delivery_lastname}' => $delivery->lastname,                     '{delivery_address1}' => $delivery->address1,                     '{delivery_address2}' => $delivery->address2,                     '{delivery_city}' => $delivery->city,                     '{delivery_postal_code}' => $delivery->postcode,                     '{delivery_country}' => $delivery->country,                     '{delivery_state}' => $delivery->id_state ? $delivery_state->name : '',                     '{delivery_phone}' => ($delivery->phone) ? $delivery->phone : $delivery->phone_mobile,                     '{delivery_other}' => $delivery->other,                     '{invoice_company}' => $invoice->company,                     '{invoice_vat_number}' => $invoice->vat_number,                     '{invoice_firstname}' => $invoice->firstname,                     '{invoice_lastname}' => $invoice->lastname,                     '{invoice_address2}' => $invoice->address2,                     '{invoice_address1}' => $invoice->address1,                     '{invoice_city}' => $invoice->city,                     '{invoice_postal_code}' => $invoice->postcode,                     '{invoice_country}' => $invoice->country,                     '{invoice_state}' => $invoice->id_state ? $invoice_state->name : '',                     '{invoice_phone}' => ($invoice->phone) ? $invoice->phone : $invoice->phone_mobile,                     '{invoice_other}' => $invoice->other,                     '{order_name}' => $order->getuniqreference(),                     '{date}' => tools::displaydate(date('y-m-d h:i:s'), null, 1),                     '{carrier}' => ($virtual_product || !isset($carrier->name)) ? tools::displayerror('no carrier') : $carrier->name,                     '{payment}' => tools::substr($order->payment, 0, 32),                     '{products}' => $product_list_html,                     '{products_txt}' => $product_list_txt,                     '{discounts}' => $cart_rules_list_html,                     '{discounts_txt}' => $cart_rules_list_txt,                     '{total_paid}' => tools::displayprice($order->total_paid, $this->context->currency, false),                     '{total_products}' => tools::displayprice(product::gettaxcalculationmethod() == ps_tax_exc ? $order->total_products : $order->total_products_wt, $this->context->currency, false),                     '{total_discounts}' => tools::displayprice($order->total_discounts, $this->context->currency, false),                     '{total_shipping}' => tools::displayprice($order->total_shipping, $this->context->currency, false),                     '{total_wrapping}' => tools::displayprice($order->total_wrapping, $this->context->currency, false),                     '{total_tax_paid}' => tools::displayprice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $this->context->currency, false));                      if (is_array($extra_vars)) {                         $data = array_merge($data, $extra_vars);                     }                      // join pdf invoice                     if ((int)configuration::get('ps_invoice') && $order_status->invoice && $order->invoice_number) {                         $order_invoice_list = $order->getinvoicescollection();                         hook::exec('actionpdfinvoicerender', array('order_invoice_list' => $order_invoice_list));                         $pdf = new pdf($order_invoice_list, pdf::template_invoice, $this->context->smarty);                         $file_attachement['content'] = $pdf->render(false);                         $file_attachement['name'] = configuration::get('ps_invoice_prefix', (int)$order->id_lang, null, $order->id_shop).sprintf('%06d', $order->invoice_number).'.pdf';                         $file_attachement['mime'] = 'application/pdf';                     } else {                         $file_attachement = null;                     }                      if (self::debug_mode) {                         prestashoplogger::addlog('paymentmodule::validateorder - mail sent', 1, null, 'cart', (int)$id_cart, true);                     }                      if (validate::isemail($this->context->customer->email)) {                         mail::send(                             (int)$order->id_lang,                             'order_conf',                             mail::l('order confirmation', (int)$order->id_lang),                             $data,                             $this->context->customer->email,                             $this->context->customer->firstname.' '.$this->context->customer->lastname,                             null,                             null,                             $file_attachement,                             null, _ps_mail_dir_, false, (int)$order->id_shop                         );                     }                 }                  // updates stock in shops                 if (configuration::get('ps_advanced_stock_management')) {                     $product_list = $order->getproducts();                     foreach ($product_list $product) {                         // if available quantities depends on physical stock                         if (stockavailable::dependsonstock($product['product_id'])) {                             // synchronizes                             stockavailable::synchronize($product['product_id'], $order->id_shop);                         }                     }                 }                  $order->updateorderdetailtax();             } else {                 $error = tools::displayerror('order creation failed');                 prestashoplogger::addlog($error, 4, '0000002', 'cart', intval($order->id_cart));                 die($error);             }         } // end foreach $order_detail_list          // use last order currentorder         if (isset($order) && $order->id) {             $this->currentorder = (int)$order->id;         }          if (self::debug_mode) {             prestashoplogger::addlog('paymentmodule::validateorder - end of validateorder', 1, null, 'cart', (int)$id_cart, true);         }          return true;     } else {         $error = tools::displayerror('cart cannot loaded or order has been placed using cart');         prestashoplogger::addlog($error, 4, '0000001', 'cart', intval($this->context->cart->id));         die($error);     } } 

you find if statement i'm trying skip @ bottom of method.

as can see, 1 of arguments, $extra_vars = array(), gets merged $data array inside function. there way skip if statement way? because have no ideas left on how solve problem.

provided $this->context->customer->email writable, like:

<?php  //...  $customeremail = $this->context->customer->email; $this->context->customer->email = null;  parent::validateorder(     $id_cart,     $id_order_state,     $amount_paid,     $payment_method,     $message,     $extra_vars,     $currency_special,     $dont_touch_amount,     $secure_key,     $shop );  $this->context->customer->email = $customeremail;    

i wouldn't advice this, if you're desperate work.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -