Conditions | 59 |
Paths | > 20000 |
Total Lines | 584 |
Code Lines | 349 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
440 | public function addOrderHistory($order_id, $order_status_id, $comment = '', $notify = false, $override = false) |
||
441 | { |
||
442 | $order_info = $this->getOrder($order_id); |
||
443 | |||
444 | if ($order_info) { |
||
445 | |||
446 | // If current order status is not processing or complete but new status is processing or complete then commence completing the order |
||
447 | if (!in_array($order_info['order_status_id'], array_merge($this->config->get('config_processing_status'), $this->config->get('config_complete_status'))) && in_array($order_status_id, array_merge($this->config->get('config_processing_status'), $this->config->get('config_complete_status')))) { |
||
448 | // Redeem reward points |
||
449 | $order_total_query = $this->db->query(" |
||
450 | SELECT * |
||
451 | FROM `order_total` |
||
452 | WHERE order_id = '" . (int)$order_id . "' |
||
453 | ORDER BY sort_order ASC |
||
454 | "); |
||
455 | |||
456 | foreach ($order_total_query->rows as $order_total) { |
||
457 | $this->load->model('extension/total/' . $order_total['code']); |
||
458 | } |
||
459 | |||
460 | // Stock subtraction |
||
461 | $order_product_query = $this->db->query(" |
||
462 | SELECT * |
||
463 | FROM order_product |
||
464 | WHERE order_id = '" . (int)$order_id . "' |
||
465 | "); |
||
466 | |||
467 | foreach ($order_product_query->rows as $order_product) { |
||
468 | $this->db->query(" |
||
469 | UPDATE product |
||
470 | SET quantity = (quantity - " . (int)$order_product['quantity'] . ") |
||
471 | WHERE product_id = '" . (int)$order_product['product_id'] . "' |
||
472 | AND subtract = '1' |
||
473 | "); |
||
474 | |||
475 | $order_option_query = $this->db->query(" |
||
476 | SELECT * |
||
477 | FROM order_option |
||
478 | WHERE order_id = '" . (int)$order_id . "' |
||
479 | AND order_product_id = '" . (int)$order_product['order_product_id'] . "' |
||
480 | "); |
||
481 | |||
482 | foreach ($order_option_query->rows as $option) { |
||
483 | $this->db->query(" |
||
484 | UPDATE product_option_value |
||
485 | SET quantity = (quantity - " . (int)$order_product['quantity'] . ") |
||
486 | WHERE product_option_value_id = '" . (int)$option['product_option_value_id'] . "' |
||
487 | AND subtract = '1' |
||
488 | "); |
||
489 | } |
||
490 | } |
||
491 | } |
||
492 | |||
493 | // Update the DB with the new statuses |
||
494 | $this->db->query(" |
||
495 | UPDATE `order` |
||
496 | SET order_status_id = '" . (int)$order_status_id . "', |
||
497 | date_modified = NOW() |
||
498 | WHERE order_id = '" . (int)$order_id . "' |
||
499 | "); |
||
500 | |||
501 | $this->db->query(" |
||
502 | INSERT INTO order_history |
||
503 | SET order_id = '" . (int)$order_id . "', |
||
504 | order_status_id = '" . (int)$order_status_id . "', |
||
505 | notify = '" . (int)$notify . "', |
||
506 | comment = '" . $this->db->escape($comment) . "', |
||
507 | date_added = NOW() |
||
508 | "); |
||
509 | |||
510 | // If old order status is the processing or complete status but new status is not then commence restock, and remove reward history |
||
511 | if (in_array($order_info['order_status_id'], array_merge($this->config->get('config_processing_status'), $this->config->get('config_complete_status'))) && !in_array($order_status_id, array_merge($this->config->get('config_processing_status'), $this->config->get('config_complete_status')))) { |
||
512 | // Restock |
||
513 | $product_query = $this->db->query(" |
||
514 | SELECT * |
||
515 | FROM order_product |
||
516 | WHERE order_id = '" . (int)$order_id . "' |
||
517 | "); |
||
518 | |||
519 | foreach ($product_query->rows as $product) { |
||
520 | $this->db->query(" |
||
521 | UPDATE `product` |
||
522 | SET quantity = (quantity + " . (int)$product['quantity'] . ") |
||
523 | WHERE product_id = '" . (int)$product['product_id'] . "' |
||
524 | AND subtract = '1' |
||
525 | "); |
||
526 | |||
527 | $option_query = $this->db->query(" |
||
528 | SELECT * |
||
529 | FROM order_option |
||
530 | WHERE order_id = '" . (int)$order_id . "' |
||
531 | AND order_product_id = '" . (int)$product['order_product_id'] . "' |
||
532 | "); |
||
533 | |||
534 | foreach ($option_query->rows as $option) { |
||
535 | $this->db->query(" |
||
536 | UPDATE product_option_value |
||
537 | SET quantity = (quantity + " . (int)$product['quantity'] . ") |
||
538 | WHERE product_option_value_id = '" . (int)$option['product_option_value_id'] . "' |
||
539 | AND subtract = '1' |
||
540 | "); |
||
541 | } |
||
542 | } |
||
543 | |||
544 | // Remove reward points history |
||
545 | $this->load->model('account/order'); |
||
546 | |||
547 | $order_total_query = $this->db->query(" |
||
548 | SELECT * |
||
549 | FROM `order_total` |
||
550 | WHERE order_id = '" . (int)$order_id . "' |
||
551 | ORDER BY sort_order ASC |
||
552 | "); |
||
553 | |||
554 | foreach ($order_total_query->rows as $order_total) { |
||
555 | $this->load->model('extension/total/' . $order_total['code']); |
||
556 | |||
557 | if (property_exists($this->{'model_extension_total_' . $order_total['code']}, 'unconfirm')) { |
||
558 | $this->{'model_extension_total_' . $order_total['code']}->unconfirm($order_id); |
||
559 | } |
||
560 | } |
||
561 | } |
||
562 | |||
563 | $this->cache->delete('product'); |
||
564 | |||
565 | // If order status is 0 then becomes greater than 0 send main html email |
||
566 | if (!$order_info['order_status_id'] && $order_status_id) { |
||
567 | // Check for any downloadable products |
||
568 | $download_status = false; |
||
569 | |||
570 | $order_product_query = $this->db->query(" |
||
571 | SELECT * |
||
572 | FROM order_product |
||
573 | WHERE order_id = '" . (int)$order_id . "' |
||
574 | "); |
||
575 | |||
576 | foreach ($order_product_query->rows as $order_product) { |
||
577 | // Check if there are any linked downloads |
||
578 | $product_download_query = $this->db->query(" |
||
579 | SELECT COUNT(*) AS total |
||
580 | FROM `product_to_download` |
||
581 | WHERE product_id = '" . (int)$order_product['product_id'] . "' |
||
582 | "); |
||
583 | |||
584 | if ($product_download_query->row['total']) { |
||
585 | $download_status = true; |
||
586 | } |
||
587 | } |
||
588 | |||
589 | // Load the language for any mails that might be required to be sent out |
||
590 | $language = new \Divine\Engine\Library\Language($order_info['language_code']); |
||
591 | $language->load($order_info['language_code']); |
||
592 | $language->load('mail/order'); |
||
593 | |||
594 | $order_status_query = $this->db->query(" |
||
595 | SELECT * |
||
596 | FROM order_status |
||
597 | WHERE order_status_id = '" . (int)$order_status_id . "' |
||
598 | AND language_id = '" . (int)$order_info['language_id'] . "' |
||
599 | "); |
||
600 | |||
601 | if ($order_status_query->num_rows) { |
||
602 | $order_status = $order_status_query->row['name']; |
||
603 | } else { |
||
604 | $order_status = ''; |
||
605 | } |
||
606 | |||
607 | $subject = sprintf($language->get('text_new_subject'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8'), $order_id); |
||
608 | |||
609 | // HTML Mail |
||
610 | $data = array(); |
||
611 | |||
612 | $data['title'] = sprintf($language->get('text_new_subject'), $order_info['store_name'], $order_id); |
||
613 | |||
614 | $data['text_greeting'] = sprintf($language->get('text_new_greeting'), $order_info['store_name']); |
||
615 | $data['text_link'] = $language->get('text_new_link'); |
||
616 | $data['text_download'] = $language->get('text_new_download'); |
||
617 | $data['text_order_detail'] = $language->get('text_new_order_detail'); |
||
618 | $data['text_instruction'] = $language->get('text_new_instruction'); |
||
619 | $data['text_order_id'] = $language->get('text_new_order_id'); |
||
620 | $data['text_date_added'] = $language->get('text_new_date_added'); |
||
621 | $data['text_payment_method'] = $language->get('text_new_payment_method'); |
||
622 | $data['text_shipping_method'] = $language->get('text_new_shipping_method'); |
||
623 | $data['text_email'] = $language->get('text_new_email'); |
||
624 | $data['text_telephone'] = $language->get('text_new_telephone'); |
||
625 | $data['text_ip'] = $language->get('text_new_ip'); |
||
626 | $data['text_order_status'] = $language->get('text_new_order_status'); |
||
627 | $data['text_payment_address'] = $language->get('text_new_payment_address'); |
||
628 | $data['text_shipping_address'] = $language->get('text_new_shipping_address'); |
||
629 | $data['text_product'] = $language->get('text_new_product'); |
||
630 | $data['text_model'] = $language->get('text_new_model'); |
||
631 | $data['text_quantity'] = $language->get('text_new_quantity'); |
||
632 | $data['text_price'] = $language->get('text_new_price'); |
||
633 | $data['text_total'] = $language->get('text_new_total'); |
||
634 | $data['text_footer'] = $language->get('text_new_footer'); |
||
635 | |||
636 | $data['logo'] = $_SERVER['DOCUMENT_ROOT'] . '/public_html/assets/images/' . $this->config->get('config_logo'); |
||
637 | $data['store_name'] = $order_info['store_name']; |
||
638 | $data['store_url'] = $order_info['store_url']; |
||
639 | $data['customer_id'] = $order_info['customer_id']; |
||
640 | $data['link'] = $order_info['store_url'] . 'index.php?route=account/order/info&order_id=' . $order_id; |
||
641 | |||
642 | if ($download_status) { |
||
643 | $data['download'] = $order_info['store_url'] . 'index.php?route=account/download'; |
||
644 | } else { |
||
645 | $data['download'] = ''; |
||
646 | } |
||
647 | |||
648 | $data['order_id'] = $order_id; |
||
649 | $data['date_added'] = date($language->get('date_format_short'), strtotime($order_info['date_added'])); |
||
650 | $data['payment_method'] = $order_info['payment_method']; |
||
651 | $data['shipping_method'] = $order_info['shipping_method']; |
||
652 | $data['email'] = $order_info['email']; |
||
653 | $data['telephone'] = $order_info['telephone']; |
||
654 | $data['ip'] = $order_info['ip']; |
||
655 | $data['order_status'] = $order_status; |
||
656 | |||
657 | if ($comment && $notify) { |
||
658 | $data['comment'] = nl2br($comment); |
||
659 | } else { |
||
660 | $data['comment'] = ''; |
||
661 | } |
||
662 | |||
663 | if ($order_info['payment_address_format']) { |
||
664 | $format = $order_info['payment_address_format']; |
||
665 | } else { |
||
666 | $format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}'; |
||
667 | } |
||
668 | |||
669 | $find = array( |
||
670 | '{firstname}', |
||
671 | '{lastname}', |
||
672 | '{company}', |
||
673 | '{address_1}', |
||
674 | '{address_2}', |
||
675 | '{city}', |
||
676 | '{postcode}', |
||
677 | '{zone}', |
||
678 | '{zone_code}', |
||
679 | '{country}' |
||
680 | ); |
||
681 | |||
682 | $replace = array( |
||
683 | 'firstname' => $order_info['payment_firstname'], |
||
684 | 'lastname' => $order_info['payment_lastname'], |
||
685 | 'company' => $order_info['payment_company'], |
||
686 | 'address_1' => $order_info['payment_address_1'], |
||
687 | 'address_2' => $order_info['payment_address_2'], |
||
688 | 'city' => $order_info['payment_city'], |
||
689 | 'postcode' => $order_info['payment_postcode'], |
||
690 | 'zone' => $order_info['payment_zone'], |
||
691 | 'zone_code' => $order_info['payment_zone_code'], |
||
692 | 'country' => $order_info['payment_country'] |
||
693 | ); |
||
694 | |||
695 | $data['payment_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format)))); |
||
696 | |||
697 | if ($order_info['shipping_address_format']) { |
||
698 | $format = $order_info['shipping_address_format']; |
||
699 | } else { |
||
700 | $format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}'; |
||
701 | } |
||
702 | |||
703 | $find = array( |
||
704 | '{firstname}', |
||
705 | '{lastname}', |
||
706 | '{company}', |
||
707 | '{address_1}', |
||
708 | '{address_2}', |
||
709 | '{city}', |
||
710 | '{postcode}', |
||
711 | '{zone}', |
||
712 | '{zone_code}', |
||
713 | '{country}' |
||
714 | ); |
||
715 | |||
716 | $replace = array( |
||
717 | 'firstname' => $order_info['shipping_firstname'], |
||
718 | 'lastname' => $order_info['shipping_lastname'], |
||
719 | 'company' => $order_info['shipping_company'], |
||
720 | 'address_1' => $order_info['shipping_address_1'], |
||
721 | 'address_2' => $order_info['shipping_address_2'], |
||
722 | 'city' => $order_info['shipping_city'], |
||
723 | 'postcode' => $order_info['shipping_postcode'], |
||
724 | 'zone' => $order_info['shipping_zone'], |
||
725 | 'zone_code' => $order_info['shipping_zone_code'], |
||
726 | 'country' => $order_info['shipping_country'] |
||
727 | ); |
||
728 | |||
729 | $data['shipping_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format)))); |
||
730 | |||
731 | $this->load->model('tool/upload'); |
||
732 | |||
733 | // Products |
||
734 | $data['products'] = array(); |
||
735 | |||
736 | foreach ($order_product_query->rows as $product) { |
||
737 | $option_data = array(); |
||
738 | |||
739 | $order_option_query = $this->db->query(" |
||
740 | SELECT * |
||
741 | FROM order_option |
||
742 | WHERE order_id = '" . (int)$order_id . "' |
||
743 | AND order_product_id = '" . (int)$product['order_product_id'] . "' |
||
744 | "); |
||
745 | |||
746 | foreach ($order_option_query->rows as $option) { |
||
747 | if ($option['type'] != 'file') { |
||
748 | $value = $option['value']; |
||
749 | } else { |
||
750 | $upload_info = $this->model_tool_upload->getUploadByCode($option['value']); |
||
751 | |||
752 | if ($upload_info) { |
||
753 | $value = $upload_info['name']; |
||
754 | } else { |
||
755 | $value = ''; |
||
756 | } |
||
757 | } |
||
758 | |||
759 | $option_data[] = array( |
||
760 | 'name' => $option['name'], |
||
761 | 'value' => (\voku\helper\UTF8::strlen($value) > 20 ? \voku\helper\UTF8::substr($value, 0, 20) . '..' : $value) |
||
762 | ); |
||
763 | } |
||
764 | |||
765 | $data['products'][] = array( |
||
766 | 'name' => $product['name'], |
||
767 | 'model' => $product['model'], |
||
768 | 'option' => $option_data, |
||
769 | 'quantity' => $product['quantity'], |
||
770 | 'price' => $this->currency->format($product['price'], $order_info['currency_code'], $order_info['currency_value']), |
||
771 | 'total' => $this->currency->format($product['total'], $order_info['currency_code'], $order_info['currency_value']) |
||
772 | ); |
||
773 | } |
||
774 | |||
775 | // Order Totals |
||
776 | $data['totals'] = array(); |
||
777 | |||
778 | $order_total_query = $this->db->query("SELECT * FROM `order_total` WHERE order_id = '" . (int)$order_id . "' ORDER BY sort_order ASC"); |
||
779 | |||
780 | foreach ($order_total_query->rows as $total) { |
||
781 | $data['totals'][] = array( |
||
782 | 'title' => $total['title'], |
||
783 | 'text' => $this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value']), |
||
784 | ); |
||
785 | } |
||
786 | |||
787 | // Text Mail |
||
788 | $text = sprintf($language->get('text_new_greeting'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8')) . "\n\n"; |
||
789 | $text .= $language->get('text_new_order_id') . ' ' . $order_id . "\n"; |
||
790 | $text .= $language->get('text_new_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_info['date_added'])) . "\n"; |
||
791 | $text .= $language->get('text_new_order_status') . ' ' . $order_status . "\n\n"; |
||
792 | |||
793 | if ($comment && $notify) { |
||
794 | $text .= $language->get('text_new_instruction') . "\n\n"; |
||
795 | $text .= $comment . "\n\n"; |
||
796 | } |
||
797 | |||
798 | // Products |
||
799 | $text .= $language->get('text_new_products') . "\n"; |
||
800 | |||
801 | foreach ($order_product_query->rows as $product) { |
||
802 | $text .= $product['quantity'] . 'x ' . $product['name'] . ' (' . $product['model'] . ') ' . html_entity_decode($this->currency->format($product['total'], $order_info['currency_code'], $order_info['currency_value']), ENT_NOQUOTES, 'UTF-8') . "\n"; |
||
803 | |||
804 | $order_option_query = $this->db->query(" |
||
805 | SELECT * |
||
806 | FROM order_option |
||
807 | WHERE order_id = '" . (int)$order_id . "' |
||
808 | AND order_product_id = '" . $product['order_product_id'] . "' |
||
809 | "); |
||
810 | |||
811 | foreach ($order_option_query->rows as $option) { |
||
812 | if ($option['type'] != 'file') { |
||
813 | $value = $option['value']; |
||
814 | } else { |
||
815 | $upload_info = $this->model_tool_upload->getUploadByCode($option['value']); |
||
816 | |||
817 | if ($upload_info) { |
||
818 | $value = $upload_info['name']; |
||
819 | } else { |
||
820 | $value = ''; |
||
821 | } |
||
822 | } |
||
823 | |||
824 | $text .= chr(9) . '-' . $option['name'] . ' ' . (\voku\helper\UTF8::strlen($value) > 20 ? \voku\helper\UTF8::substr($value, 0, 20) . '..' : $value) . "\n"; |
||
825 | } |
||
826 | } |
||
827 | |||
828 | $text .= "\n"; |
||
829 | |||
830 | $text .= $language->get('text_new_order_total') . "\n"; |
||
831 | |||
832 | foreach ($order_total_query->rows as $total) { |
||
833 | $text .= $total['title'] . ': ' . html_entity_decode($this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value']), ENT_NOQUOTES, 'UTF-8') . "\n"; |
||
834 | } |
||
835 | |||
836 | $text .= "\n"; |
||
837 | |||
838 | if ($order_info['customer_id']) { |
||
839 | $text .= $language->get('text_new_link') . "\n"; |
||
840 | $text .= $order_info['store_url'] . 'index.php?route=account/order/info&order_id=' . $order_id . "\n\n"; |
||
841 | } |
||
842 | |||
843 | if ($download_status) { |
||
844 | $text .= $language->get('text_new_download') . "\n"; |
||
845 | $text .= $order_info['store_url'] . 'index.php?route=account/download' . "\n\n"; |
||
846 | } |
||
847 | |||
848 | // Comment |
||
849 | if ($order_info['comment']) { |
||
850 | $text .= $language->get('text_new_comment') . "\n\n"; |
||
851 | $text .= $order_info['comment'] . "\n\n"; |
||
852 | } |
||
853 | |||
854 | $text .= $language->get('text_new_footer') . "\n\n"; |
||
855 | |||
856 | $mail = new \Divine\Engine\Library\Mail(); |
||
857 | $mail->protocol = $this->config->get('config_mail_protocol'); |
||
858 | $mail->parameter = $this->config->get('config_mail_parameter'); |
||
859 | $mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname'); |
||
860 | $mail->smtp_username = $this->config->get('config_mail_smtp_username'); |
||
861 | $mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8'); |
||
862 | $mail->smtp_port = $this->config->get('config_mail_smtp_port'); |
||
863 | $mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout'); |
||
864 | |||
865 | $mail->setTo($order_info['email']); |
||
866 | $mail->setFrom($this->config->get('config_email')); |
||
867 | $mail->setSender(html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8')); |
||
868 | $mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8')); |
||
869 | $mail->setHtml($this->load->view('mail/order', $data)); |
||
870 | $mail->setText($text); |
||
871 | $mail->send(); |
||
872 | |||
873 | // Admin Alert Mail |
||
874 | if (in_array('order', (array)$this->config->get('config_mail_alert'))) { |
||
875 | $subject = sprintf($language->get('text_new_subject'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'), $order_id); |
||
876 | |||
877 | // HTML Mail |
||
878 | $data['text_greeting'] = $language->get('text_new_received'); |
||
879 | |||
880 | if ($comment) { |
||
881 | if ($order_info['comment']) { |
||
882 | $data['comment'] = nl2br($comment) . '<br/><br/>' . $order_info['comment']; |
||
883 | } else { |
||
884 | $data['comment'] = nl2br($comment); |
||
885 | } |
||
886 | } else { |
||
887 | if ($order_info['comment']) { |
||
888 | $data['comment'] = $order_info['comment']; |
||
889 | } else { |
||
890 | $data['comment'] = ''; |
||
891 | } |
||
892 | } |
||
893 | |||
894 | $data['text_download'] = ''; |
||
895 | |||
896 | $data['text_footer'] = ''; |
||
897 | |||
898 | $data['text_link'] = ''; |
||
899 | $data['link'] = ''; |
||
900 | $data['download'] = ''; |
||
901 | |||
902 | // Text |
||
903 | $text = $language->get('text_new_received') . "\n\n"; |
||
904 | $text .= $language->get('text_new_order_id') . ' ' . $order_id . "\n"; |
||
905 | $text .= $language->get('text_new_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_info['date_added'])) . "\n"; |
||
906 | $text .= $language->get('text_new_order_status') . ' ' . $order_status . "\n\n"; |
||
907 | $text .= $language->get('text_new_products') . "\n"; |
||
908 | |||
909 | foreach ($order_product_query->rows as $product) { |
||
910 | $text .= $product['quantity'] . 'x ' . $product['name'] . ' (' . $product['model'] . ') ' . html_entity_decode($this->currency->format($product['total'], $order_info['currency_code'], $order_info['currency_value']), ENT_NOQUOTES, 'UTF-8') . "\n"; |
||
911 | |||
912 | $order_option_query = $this->db->query(" |
||
913 | SELECT * |
||
914 | FROM order_option |
||
915 | WHERE order_id = '" . (int)$order_id . "' |
||
916 | AND order_product_id = '" . $product['order_product_id'] . "' |
||
917 | "); |
||
918 | |||
919 | foreach ($order_option_query->rows as $option) { |
||
920 | if ($option['type'] != 'file') { |
||
921 | $value = $option['value']; |
||
922 | } else { |
||
923 | $value = \voku\helper\UTF8::substr($option['value'], 0, \voku\helper\UTF8::strrpos($option['value'], '.')); |
||
924 | } |
||
925 | |||
926 | $text .= chr(9) . '-' . $option['name'] . ' ' . (\voku\helper\UTF8::strlen($value) > 20 ? \voku\helper\UTF8::substr($value, 0, 20) . '..' : $value) . "\n"; |
||
927 | } |
||
928 | } |
||
929 | |||
930 | $text .= "\n"; |
||
931 | |||
932 | $text .= $language->get('text_new_order_total') . "\n"; |
||
933 | |||
934 | foreach ($order_total_query->rows as $total) { |
||
935 | $text .= $total['title'] . ': ' . html_entity_decode($this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value']), ENT_NOQUOTES, 'UTF-8') . "\n"; |
||
936 | } |
||
937 | |||
938 | $text .= "\n"; |
||
939 | |||
940 | if ($order_info['comment']) { |
||
941 | $text .= $language->get('text_new_comment') . "\n\n"; |
||
942 | $text .= $order_info['comment'] . "\n\n"; |
||
943 | } |
||
944 | |||
945 | $mail = new \Divine\Engine\Library\Mail(); |
||
946 | $mail->protocol = $this->config->get('config_mail_protocol'); |
||
947 | $mail->parameter = $this->config->get('config_mail_parameter'); |
||
948 | $mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname'); |
||
949 | $mail->smtp_username = $this->config->get('config_mail_smtp_username'); |
||
950 | $mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8'); |
||
951 | $mail->smtp_port = $this->config->get('config_mail_smtp_port'); |
||
952 | $mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout'); |
||
953 | |||
954 | $mail->setTo($this->config->get('config_email')); |
||
955 | $mail->setFrom($this->config->get('config_email')); |
||
956 | $mail->setSender(html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8')); |
||
957 | $mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8')); |
||
958 | $mail->setHtml($this->load->view('mail/order', $data)); |
||
959 | $mail->setText($text); |
||
960 | $mail->send(); |
||
961 | |||
962 | // Send to additional alert emails |
||
963 | $emails = explode(',', $this->config->get('config_alert_email')); |
||
964 | |||
965 | foreach ($emails as $email) { |
||
966 | if ($email && filter_var($email, FILTER_VALIDATE_EMAIL)) { |
||
967 | $mail->setTo($email); |
||
968 | $mail->send(); |
||
969 | } |
||
970 | } |
||
971 | } |
||
972 | } |
||
973 | |||
974 | // If order status is not 0 then send update text email |
||
975 | if ($order_info['order_status_id'] && $order_status_id && $notify) { |
||
976 | $language = new \Divine\Engine\Library\Language($order_info['language_code']); |
||
977 | $language->load($order_info['language_code']); |
||
978 | $language->load('mail/order'); |
||
979 | |||
980 | $subject = sprintf($language->get('text_update_subject'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8'), $order_id); |
||
981 | |||
982 | $message = $language->get('text_update_order') . ' ' . $order_id . "\n"; |
||
983 | $message .= $language->get('text_update_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_info['date_added'])) . "\n\n"; |
||
984 | |||
985 | $order_status_query = $this->db->query(" |
||
986 | SELECT * |
||
987 | FROM order_status |
||
988 | WHERE order_status_id = '" . (int)$order_status_id . "' |
||
989 | AND language_id = '" . (int)$order_info['language_id'] . "' |
||
990 | "); |
||
991 | |||
992 | if ($order_status_query->num_rows) { |
||
993 | $message .= $language->get('text_update_order_status') . "\n\n"; |
||
994 | $message .= $order_status_query->row['name'] . "\n\n"; |
||
995 | } |
||
996 | |||
997 | if ($order_info['customer_id']) { |
||
998 | $message .= $language->get('text_update_link') . "\n"; |
||
999 | $message .= $order_info['store_url'] . 'index.php?route=account/order/info&order_id=' . $order_id . "\n\n"; |
||
1000 | } |
||
1001 | |||
1002 | if ($comment) { |
||
1003 | $message .= $language->get('text_update_comment') . "\n\n"; |
||
1004 | $message .= strip_tags($comment) . "\n\n"; |
||
1005 | } |
||
1006 | |||
1007 | $message .= $language->get('text_update_footer'); |
||
1008 | |||
1009 | $mail = new \Divine\Engine\Library\Mail(); |
||
1010 | $mail->protocol = $this->config->get('config_mail_protocol'); |
||
1011 | $mail->parameter = $this->config->get('config_mail_parameter'); |
||
1012 | $mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname'); |
||
1013 | $mail->smtp_username = $this->config->get('config_mail_smtp_username'); |
||
1014 | $mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8'); |
||
1015 | $mail->smtp_port = $this->config->get('config_mail_smtp_port'); |
||
1016 | $mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout'); |
||
1017 | |||
1018 | $mail->setTo($order_info['email']); |
||
1019 | $mail->setFrom($this->config->get('config_email')); |
||
1020 | $mail->setSender(html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8')); |
||
1021 | $mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8')); |
||
1022 | $mail->setText($message); |
||
1023 | $mail->send(); |
||
1024 | } |
||
1028 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.