Jump to content

Spouter

Members
  • Posts

    22
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Spouter's Achievements

Apprentice

Apprentice (3/14)

  • Dedicated Rare
  • First Post Rare
  • Collaborator Rare
  • Conversation Starter Rare
  • Week One Done Rare

Recent Badges

1

Reputation

  1. I'm looking for paid module adjustment. I need to made some changes in PosSpecialProducts module. Module is showing products with special price on homepage. Standard sort options are by id, name, postion, date. I need to add another one by "random". Is someone here who is able to do this? For money, of course. Here is main module code *edit Code removed
  2. I'm looking for prestashop customization for sending PDF credit slips wia mails at attachment.
  3. Hello, I'm trying to do same for 1.7.8 version. But there is no AdminOrdersController.php I found similar file in classes/order/OrderHistory.php where is public function sendEmail($order, $template_vars = false) { $result = Db::getInstance()->getRow(' SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, c.`email`, os.`module_name`, os.`id_order_state`, os.`pdf_invoice`, os.`pdf_delivery` FROM `' . _DB_PREFIX_ . 'order_history` oh LEFT JOIN `' . _DB_PREFIX_ . 'orders` o ON oh.`id_order` = o.`id_order` LEFT JOIN `' . _DB_PREFIX_ . 'customer` c ON o.`id_customer` = c.`id_customer` LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON oh.`id_order_state` = os.`id_order_state` LEFT JOIN `' . _DB_PREFIX_ . 'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = o.`id_lang`) WHERE oh.`id_order_history` = ' . (int) $this->id . ' AND os.`send_email` = 1'); if (isset($result['template']) && Validate::isEmail($result['email'])) { ShopUrl::cacheMainDomainForShop($order->id_shop); $topic = $result['osname']; $carrierUrl = ''; if (Validate::isLoadedObject($carrier = new Carrier((int) $order->id_carrier, $order->id_lang))) { $carrierUrl = $carrier->url; } $data = [ '{lastname}' => $result['lastname'], '{firstname}' => $result['firstname'], '{id_order}' => (int) $this->id_order, '{order_name}' => $order->getUniqReference(), '{followup}' => str_replace('@', $order->getWsShippingNumber(), $carrierUrl), '{shipping_number}' => $order->getWsShippingNumber(), ]; if ($result['module_name']) { $module = Module::getInstanceByName($result['module_name']); if (Validate::isLoadedObject($module) && isset($module->extra_mail_vars) && is_array($module->extra_mail_vars)) { $data = array_merge($data, $module->extra_mail_vars); } } if (is_array($template_vars)) { $data = array_merge($data, $template_vars); } $context = Context::getContext(); $data['{total_paid}'] = Tools::getContextLocale($context)->formatPrice((float) $order->total_paid, Currency::getIsoCodeById((int) $order->id_currency)); if (Validate::isLoadedObject($order)) { // Attach invoice and / or delivery-slip if they exists and status is set to attach them if (($result['pdf_invoice'] || $result['pdf_delivery'])) { $currentLanguage = $context->language; $orderLanguage = new Language((int) $order->id_lang); $context->language = $orderLanguage; $context->getTranslator()->setLocale($orderLanguage->locale); $invoice = $order->getInvoicesCollection(); $file_attachement = []; if ($result['pdf_invoice'] && (int) Configuration::get('PS_INVOICE') && $order->invoice_number) { Hook::exec('actionPDFInvoiceRender', ['order_invoice_list' => $invoice]); $pdf = new PDF($invoice, PDF::TEMPLATE_INVOICE, $context->smarty); $file_attachement['invoice']['content'] = $pdf->render(false); $file_attachement['invoice']['name'] = Configuration::get('PS_INVOICE_PREFIX', (int) $order->id_lang, null, $order->id_shop) . sprintf('%06d', $order->invoice_number) . '.pdf'; $file_attachement['invoice']['mime'] = 'application/pdf'; } if ($result['pdf_delivery'] && $order->delivery_number) { $pdf = new PDF($invoice, PDF::TEMPLATE_DELIVERY_SLIP, $context->smarty); $file_attachement['delivery']['content'] = $pdf->render(false); $file_attachement['delivery']['name'] = Configuration::get('PS_DELIVERY_PREFIX', (int) $order->id_lang, null, $order->id_shop) . sprintf('%06d', $order->delivery_number) . '.pdf'; $file_attachement['delivery']['mime'] = 'application/pdf'; } $context->language = $currentLanguage; $context->getTranslator()->setLocale($currentLanguage->locale); } else { $file_attachement = null; } if (!Mail::Send( (int) $order->id_lang, $result['template'], $topic, $data, $result['email'], $result['firstname'] . ' ' . $result['lastname'], null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int) $order->id_shop )) { return false; } } ShopUrl::resetMainDomainCache(); } return true; } Probably best place is in "else" where is $file_attachement = null; But i dont know how to determinate when order has credit slip and when not. If there is anyone who is able to do it for 1.7.8.1 - I will buy him more than one coffee I need attach credit slip to "credit_slip" e-mail template and change order status to custom status with ID 17.
  4. As always - this forum is dead... Maybe it help someone: public function hookHeader($params) { Media::addJsDef( array( 'currency_id' => (int)$this->context->currency->id, 'conversion_rate' => Context::getContext()->currency->getConversionRate(), ) ); }
  5. I see in PS code some prestashop variables in <head> section. For example "var prestashop". Than i can access these variables in js files for example "prestashop.currency.iso_code" will print "EUR" in my case. But how can I add new variables? I need to add all available currencies with conversions rates.
  6. Tak jsem si kontrolu políček napsal sám - funguje to na přihlašovací formulář, registrační formulář (ověřuje to PSČ i telefon, telefon jen pro ČR a SR), formulář s adresou, formulář s osobními údaji. Dále je upraven poslední krok strandarního objednávkového procesu a to "Platební metoda". Funguje zde kontrola zatržení obch. podmínek a kontrola výběru platební metody. Kód stačí přidat do "(document).ready" např. v .js souboru vzhledu. function IsEmail(email) { var regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; if(!regex.test(email)) { return false; }else{ return true; } } function IsPostcode(postcode) { var regex = /^[0-9]{3} [0-9]{2}$/; if(!regex.test(postcode)) { return false; }else{ return true; } } function IsPhone(tel) { var regex = /^((\+420)|(\+421))?( )?[0-9]{3}( )?[0-9]{3}( )?[0-9]{3}$/; if(!regex.test(tel)) { return false; }else{ return true; } } function betterFormValidation() { var form = $('#content form button[type=submit]').closest('form'); var formValue = form.find(':input:not(:hidden)').serialize(); $(form).find('input[type="email"][required]').not('input[type="hidden"]').each(function() { if(!IsEmail(this.value)) { if (!$(this).hasClass('error-mail')) { $(this).addClass('error-mail'); $(this).addClass('errc'); $(this).after('<div class="error-msg-mail"> E-mailová adresa má chybný formát.</div>'); } } else { $(this).removeClass('error-mail'); $(this).removeClass('errc'); $(this).next(".error-msg-mail").remove(); } }); $(form).find('input[type="text"][required][name="postcode"]').not('input[type="hidden"]').each(function() { if(!IsPostcode(this.value)) { if (!$(this).hasClass('error-postcode')) { $(this).addClass('error-postcode'); $(this).addClass('errc'); $(this).after('<div class="error-msg-postcode">PSČ má chybný formát. Nezapomeňte na mezeru. Příklad PSČ: "123 01".</div>'); } } else { $(this).removeClass('error-postcode'); $(this).removeClass('errc'); $(this).next(".error-msg-postcode").remove(); } }); $(form).find('input[type="tel"][required][name="phone"]').not('input[type="hidden"]').each(function() { if(!IsPhone(this.value)) { if (!$(this).hasClass('error-phone')) { $(this).addClass('error-phone'); $(this).addClass('errc'); $(this).after('<div class="error-msg-phone">Telefon má chybný formát. Zadávejte ve formátu např.: "+420 777 123 456 nebo +420 777123456".</div>'); } } else { $(this).removeClass('error-phone'); $(this).removeClass('errc'); $(this).next(".error-msg-phone").remove(); } }); $(form).find('input[name="password"][required]').not('input[type="hidden"]').each(function() { if(this.value.length < 5) { if (!$(this).hasClass('error-password')) { $(this).addClass('error-password'); $(this).addClass('errc'); $(this).after('<div class="error-msg-pswd"> Heslo má chybný formát. Heslo musí být minimálně 5 znaků dlouhé.</div>'); } } else { $(this).removeClass('error-password'); $(this).removeClass('errc'); $(this).next(".error-msg-pswd").remove(); } }); $(form).find('input[type="checkbox"][required]').each(function() { if($(this).prop("checked") == false) { if(!$(this).hasClass('error-checkbox')) { $(this).addClass('error-checkbox'); $(this).addClass('errc'); $(this).before('<div class="error-msg">Je nutné zaškrtnout povinné políčko.</div>'); } } else { $(this).removeClass('error-checkbox'); $(this).removeClass('errc'); $(this).prev(".error-msg").remove(); } }); $(form).find('input[type="text"][required], input[type="email"][required], input[type="password"][required], input[type="tel"][required]').not('input[type="hidden"]').each(function() { if(this.value == '') { if (!$(this).hasClass('error-blank')) { $(this).addClass('error-blank'); $(this).addClass('errc'); $(this).after('<div class="error-msg">Pole je povinné - je nutné jej vyplnit.</div>'); } } else { $(this).removeClass('error-blank'); $(this).removeClass('errc'); $(this).next(".error-msg").remove(); } }); if ($('.errc').length == 0) { return true; } else { return false; } } $('#content form button[type=submit]').on('click', function (event) { var form = $(this).closest('form'); $(form).addClass('form-submited'); if (!betterFormValidation()) { event.preventDefault(); } }); $('#content form input').focusout(function(){ if ($(this).closest('form').hasClass("form-submited")) { betterFormValidation(); } }); $('#content form input').keyup(function(){ if ($(this).closest('form').hasClass("form-submited")) { betterFormValidation(); } }); $('#content form input[type=checkbox]').on('click', function () { if ($(this).closest('form').hasClass("form-submited")) { betterFormValidation(); } }); // Formulář u platební metody var textButton = $('#payment-confirmation button[type=submit]').text(); $('#payment-confirmation button[type=submit]').after('<a class="abtn-confirm">'+textButton+'</a>'); $('#payment-confirmation button[type=submit]').addClass('no-display'); function betterPaymentValidation() { var divPayment = $('#payment-confirmation button[type=submit]').closest('#checkout-payment-step'); var numChecked = 0; $(divPayment).find('input[type="radio"][name="payment-option"][required]').each(function() { if ($(this).prop("checked") == false) { $(this).addClass('error-payment-method'); $(this).parent().addClass('errc'); } else { numChecked++; } }); var numMethods = $('input[type="radio"][name="payment-option"][required]').length; if (numChecked == 0 && $('.error-msg-payment').length == 0) { $('#checkout-payment-step .payment-options').before('<div class="error-msg-payment">Musíte si vybrat jednu platební metodu.</div>'); } if(numChecked >= 1) { $('.payment-option .custom-radio').removeClass('errc'); $("#checkout-payment-step .error-msg-payment").remove(); } $(divPayment).find('input[type="checkbox"][required]').each(function() { if($(this).prop("checked") == false) { if(!$(this).hasClass('error-checkbox')) { $(this).addClass('error-checkbox'); $(this).addClass('errc'); $(this).parent().parent().before('<div class="error-msg">Objednávku nelze dokončit bez souhlasu s podmínkami.</div>'); $('#payment-confirmation button[type=submit]').addClass('no-display'); $('.abtn-confirm').show(); } } else { $(this).removeClass('error-checkbox'); $(this).removeClass('errc'); $(this).parent().parent().prev(".error-msg").remove(); } }); if ($('.errc').length == 0) { return true; } else { return false; } } var checkMethod = $('input[type="radio"][name="payment-option"][required]:checked').length; var numCheckboxes = $('input[type="checkbox"][required]').length; var checkCheckboxes = $('input[type="checkbox"][required]:checked').length; if ((checkCheckboxes == numCheckboxes) && checkMethod >= 1) { $('.abtn-confirm').hide(); $('#payment-confirmation button[type=submit]').removeClass('no-display'); $('#payment-confirmation button[type=submit]').removeClass('disabled'); } $('#payment-confirmation button[type=submit], .abtn-confirm').on('click', function (event) { $('#checkout-payment-step').addClass('order-submited'); if (!betterPaymentValidation()) { event.preventDefault(); } else { $('.abtn-confirm').hide(); $('#payment-confirmation button[type=submit]').removeClass('no-display'); } }); $('#checkout-payment-step input[type=checkbox], #checkout-payment-step input[type=radio]').on('click', function () { if ($('#checkout-payment-step').hasClass('order-submited')) { if (betterPaymentValidation()) { $('.abtn-confirm').hide(); $('#payment-confirmation button[type=submit]').removeClass('no-display'); } } }); Dále je nutné přidat stylování opět například do .css souboru vzhledu. .error-blank, .error-mail, .error-password, .error-postcode, .error-checkbox, .error-checkbox+span { border-color: red!important; } .error-msg, .error-msg-payment { color: red!important; } #checkout-payment-step .float-xs-left { margin-top:5px; } #checkout-payment-step #payment-confirmation { text-align:right; } body#checkout .condition-label { margin-top:0; } .abtn-confirm { font-weight: 400; font-size: 14px; border: none; line-height: 25px; box-shadow: none; padding: 5px 20px; border-radius: 5px; display: inline-block; background: #1d1d1d; color: #ffffff; cursor:pointer; } .abtn-confirm:hover { color:#fff; background:#146CDA; } .errc { border-color:red; } .no-display { display:none!important; } body#checkout .additional-information { margin-top: 0px; margin-bottom: 30px; } U CSS je důležité přizpůsobit třídu .abtn-confirm a .abtn-confirm:hover, tak aby odpovídal vzhledu potvrzovacího tlačítka.
  7. Did you tried it? I dont know how to acces to fields specs? It must be somewhere something where is declared what i can write to specific input, minimum lenght, maximum lenght and some notices or error texts. I found only "we are using internal Symfony validation for forms" in developers guide. But nothing more. How is it possible that someting like live validation is not implemented in core code? PS 1.6 had live validation. PS 1.7 have Symfony a thats all. What a development! Even more and more foncionalities are missing in 1.7.
  8. Mám 1.7.8.1, tak nevím jestli je to stejné: Mezinárodní -> Lokace Poté záložka "Země" tam najít "Česká republika" a "Upravit" Následně na detailu země je box "Formát adresy" do toho boxu se musí přidat "dni". Když pole přidáš před "vat_number" tak první budeš mít v registračním formuláři IČ a poté DIČ. //* Jinak bývá zvykem, že si na foru všichni tykají...
  9. verze 1.7 má IČ i DIČ. I verze 1.6 měla IČ - pole se v originále jmenuje "dni" a je nutné jej přidat u dané země tj. ČR do formátu adresy.
  10. cuz its open source... and we have to profit on it
  11. OK, but how? I will be fully satisfied if i manage to add custom class for example "error" to all missing fields. But standard PS validation is adding no flag to missing fields. And i dont know how to do that - symfony is to complicated for me. I'm only html/css coder not programmer.
  12. How to add custom class for example "error" to requiered fields when customer forget to fill them? For example in registration form. When customer forget to fill multiple fields and click on Submit how to highlight all that missing fields?
  13. Jak máte vyřešenu kontrolu polí ve formulářích ve verzi 1.7? Jsem se zděsil, že standardní kontrola například při registraci nového zákaznického účtu je jen pomocí fokusování na první nevyplněné políčko. Když zákazník nevyplní více polí, tak se nic nezvýrazní např. červené pozadí u políčka, červený křížek ba ani se neukáže chybová hláška. Tohhle přeci nikdo nemůže v ostrém provozu používat? Zákazník například zapomene vyplnit políčko příjmení a podmínky ochrany osobních údajů a místo aby se obě políčka označila a vypsaly se chybové hlášky u těchto políček, tak se zobrazí jen basic prohlížečová chybová hláška "pole je povinné" a to jen u toho prvního nevyplněného pole. Nic se nezvýrazní, že je nutné doplnit / vyplnit.... Řešíte to nějak po svém? Máte to nějak overridnuté nebo je na to nějaký modul?
  14. I'm not OK with standard front office forms validation. When customer forget to fill some fileds after submiting only first filed is focused. All fields are validate one by one. Is there way to validate all fields together? For example add new class to all reqiered fields with highlighted background / borders... PS 1.6 had better validation. You had to reload page, but every missings fields was highlited and customer were able to fixed them immadiatly. Error messages were printed and everything was clear right away. Now you have to checked each field one by one - no message is show only browser tooltip "field is required"... How did you manage this? Is there any module how to make this terrible basic validation better?
×
×
  • Create New...