Jump to content

Pedro Lima

Members
  • Posts

    97
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Pedro Lima

  1. @EvaF thank you for your kind help. Unfortunately, this is not the problem because if this was the problem, it would be "blocked" by the verification of the control cariable $emailControl that I created to avoid multiple emails being sent on one iteration inside foreach loop. So even if there was more than one repeated email associated to those variables, it would actually never enter inside that "if" condition and would simply "jump" that one. BUT... and this is the big question actually! Repeated emails WOULD go inside the loop hence they are not ordered. This means that if the same email was on result 1 and 3 but not in 2, it would send it anyway because the control variable is not an array of emails but instead a simple variable. So the solution here was actually quite simple to avoid this problem: "ORDER BY cu.email" right in the end of the query. Anyway, thank you for your input once again because thanks to you, I was forced to think outside of what I had here and found the possible solution for the problem.
  2. So I have this code that, for some reason, happens to send repeated emails. Sometimes it sends out 2, other times 3, 4, 5 repeated emails at once for the very same customer, I simply don't know what's happening. I have already tried so many things and nothing seems to work out. Can someone figure out something here? private function cancelledCart($count = false) { $CemailControl = 0; $emailControl = 0; $email_logs = $this->getLogsEmail(1); $sql = 'SELECT c.id_cart, c.id_lang, cu.id_customer, c.id_shop, cu.firstname, cu.lastname, cu.email, ad.phone_mobile FROM '._DB_PREFIX_.'cart c LEFT JOIN '._DB_PREFIX_.'orders o ON (o.id_cart = c.id_cart) LEFT JOIN '._DB_PREFIX_.'order_history oh ON (oh.id_order = o.id_order) LEFT JOIN '._DB_PREFIX_.'address ad ON (c.id_customer = ad.id_customer) RIGHT JOIN '._DB_PREFIX_.'customer cu ON (cu.id_customer = c.id_customer) RIGHT JOIN '._DB_PREFIX_.'cart_product cp ON (cp.id_cart = c.id_cart) WHERE DATE_SUB(CURDATE(),INTERVAL 90 DAY) <= c.date_add AND o.valid = 0 AND oh.id_order_state = "6" AND cu.newsletter = 1'; $sql .= Shop::addSqlRestriction(Shop::SHARE_CUSTOMER, 'c'); if (!empty($email_logs)) $sql .= ' AND c.id_cart NOT IN ('.join(',', $email_logs).') GROUP BY cu.email'; $emails = Db::getInstance()->executeS($sql); $conf = Configuration::getMultiple(array('REMARKETING_AMOUNT_1', 'REMARKETING_DAYS_1', 'REMARKETING_ENABLE_11', 'REMARKETING_CUSTOMER_ID_1', 'REMARKETING_EMAIL_TYPE_MANUAL')); if ($conf['REMARKETING_ENABLE_11'] && $conf['REMARKETING_EMAIL_TYPE_MANUAL'] == 'cancelled') { $cids = $conf['REMARKETING_CUSTOMER_ID_1']; $sql = 'SELECT c.id_customer, c.firstname, c.lastname, c.email, c.id_lang, ad.phone_mobile FROM '._DB_PREFIX_.'customer c LEFT JOIN '._DB_PREFIX_.'address ad ON (c.id_customer = ad.id_customer) WHERE c.id_customer IN ('.$cids.')'; $customers = Db::getInstance()->executeS($sql); foreach ($customers as $customer) { if ($CemailControl !== $customer['email']) { $voucher = $this->createDiscount(1, (float)$conf['REMARKETING_AMOUNT_1'], (int)$customer['id_customer'], strftime('%Y-%m-%d', strtotime('+'.(int)$conf['REMARKETING_DAYS_1'].' day')), $this->l('Discount for cancelled orders')); if ($voucher !== false) { $CemailControl = $customer['email']; $baseURL = Context::getContext()->shop->getBaseURL(true); $template_vars = array( '{base_url}' => $baseURL, '{email}' => $customer['email'], '{lastname}' => $customer['lastname'], '{firstname}' => $customer['firstname'], '{amount}' => $conf['REMARKETING_AMOUNT_1'], '{days}' => $conf['REMARKETING_DAYS_1'], '{voucher_num}' => $voucher->code ); Mail::Send((int)$customer['id_lang'], 'remarketing_1', Mail::l('Discount coupon for your next order', (int)$customer['id_lang']), $template_vars, $customer['email'], $customer['firstname'].' '.$customer['lastname'], null, null, null, null, dirname(__FILE__).'/mails/'); if ((int)Configuration::get('REMARKETING_ENABLE_0') == '1' && $customer['phone_mobile'] != '') $this->send_message(Configuration::get('REMARKETING_SMS_COUNTRY_CODE').$customer['phone_mobile'], Tools::substr(Configuration::get('PS_SHOP_NAME'), 0, 40), sprintf($this->l('Use this coupon on your next order: %d'), $voucher->code)); } } } } if ($count || !count($emails)) return count($emails); foreach ($emails as $email) { if ($email['order_canceled'] == '6' && $emailControl !== $email['email']) { $emailControl = $email['email']; $voucher = $this->createDiscount(1, (float)$conf['REMARKETING_AMOUNT_1'], (int)$email['id_customer'], strftime('%Y-%m-%d', strtotime('+'.(int)$conf['REMARKETING_DAYS_1'].' day')), $this->l('Discount for cancelled orders')); if ($voucher !== false) { $baseURL = Context::getContext()->shop->getBaseURL(true); $template_vars = array( '{base_url}' => $baseURL, '{email}' => $email['email'], '{lastname}' => $email['lastname'], '{firstname}' => $email['firstname'], '{amount}' => $conf['REMARKETING_AMOUNT_1'], '{days}' => $conf['REMARKETING_DAYS_1'], '{voucher_num}' => $voucher->code ); Mail::Send((int)$email['id_lang'], 'remarketing_1', Mail::l('Discount coupon for your next order', (int)$email['id_lang']), $template_vars, $email['email'], $email['firstname'].' '.$email['lastname'], null, null, null, null, dirname(__FILE__).'/mails/'); $this->logEmail(1, (int)$voucher->id, (int)$email['id_customer'], (int)$email['id_cart'], 0); if ((int)Configuration::get('REMARKETING_ENABLE_0') == '1' && $email['phone_mobile'] != '') $this->send_message(Configuration::get('REMARKETING_SMS_COUNTRY_CODE').$email['phone_mobile'], Tools::substr(Configuration::get('PS_SHOP_NAME'), 0, 40), sprintf($this->l('Use this coupon on your next order: %d'), $voucher->code)); } } } } Thank you in advance for any help given.
  3. First, let me thank you @razaro Then, let me leave a reference for future visitors from what I've been trying during these last days. After a lot of trial and errors, on my little time for this matter, I now understand that in order to call CSS or JS in backoffice, I should first put this on the "public function install()", right in the end: return parent::install() && $this->registerHook('backOfficeHeader') && $this->registerHook('displayBackOfficeHeader'); After that, I can then create a function to use CSS or JS in backoffice, and for that one should do something like so: public function hookBackOfficeHeader($params) { if (_PS_VERSION_ < '1.5'){ Tools::addJS(($this->_path).'views/js/custom.js', 'all'); Tools::addCSS(($this->_path).'views/css/custom.css', 'all'); }else{ $this->context->controller->addJquery(); $this->context->controller->addJS($this->_path.'views/js/custom.js', 'all'); $this->context->controller->addCSS($this->_path.'views/css/custom.css', 'all'); } } So now back to the topic of my question, starting from your answer. It is indeed an example code and I thank you for that because thanks to this, I could start looking for solutions. Not the ones I thought in the first place, but hey it's a start! Unfortunately, the code like this it would never work, even as example code. This is my code "working": $(document).ready(function() { var opt = jQuery("#SELECT_OPT").val(); $("#SELECT_OPT").on('change', function(e) { opt = jQuery("#SELECT_OPT").val(); if ( opt == "optone" ) { $('input[name="USERNAME"]').show() $('input[name="PASSWORD"]').show(); } else { $('input[name="USERNAME"]').hide() $('input[name="PASSWORD"]').hide(); } }); }); Problem with this code, specifically for my use case, is that although it works, it does not work as intended. When "Option 1" is selected, fields appear and that's all ok. But when "Option 2" is selected, input fields do not appear and that, apparently, should be ok... but it's not! As you can see, labels are still there: So, conclusion, this is my proper working JS code: $(document).ready(function() { var opt = jQuery("#SELECT_OPT").val(); $("#SELECT_OPT").on('change', function(e) { opt = jQuery("#SELECT_OPT").val(); if ( opt == "optone" ) { $('input[name="USERNAME"]').parent().parent().parent().show() $('input[name="PASSWORD"]').parent().parent().parent().show(); } else { $('input[name="USERNAME"]').parent().parent().parent().hide() $('input[name="PASSWORD"]').parent().parent().parent().hide(); } }); }); And there we go! I just came here to leave my solved case because a lot of times I check questions like mine and then, no solution. Or when it has a solution, it's not clear and it does not help so then we need to scratch the web to find different answers to fill the puzzle. Well, this is it. See you guys next time and thank you very much once again.
  4. Hi, Thank you for your answer. Yes, it is for a new module I am personally testing but in order to make it work I need to have a selectbox. I will try to explain in steps, maybe I can be more clear, so let's see: We get inside that Module configuration page; We have a selectbox with 2 different options (let's call it Option 1 and Option 2); I can select one of those two options (the common functionality of any selectbox); If I select "Option 1", bellow that selectbox it should appear two text fields (I named those fields "Username" and "Password" but those are just text fields); No other fields should be visible, only these 2; If I select "Option 2", bellow that selectbox it should appear one field (I named that field "Some Code" and it should be just a text field); No other fields should be visible, only this 1. And that's it. I tried Googling this, I saw that there are modules doing it so it's "duable" and I just wanted to see if the community could help. If not, I understand that and this thread can be closed and I will not bother the community again with "my problems" (that can be other one problems too). But it's kinda sad because I usually use a lot other platforms and the communities are way more interactive.
  5. Is Prestashop dying? I mean, I use other Open Source solutions for ecommerce and the communities are WAYYY more interactive!
  6. $some_options = array( array( 'id_option' => 'optone', 'name' => $this->l('Option 1') ), array( 'id_option' => 'opttwo', 'name' => $this->l('Option 2') ), ); $fields_form = array( 'form' => array( 'legend' => array( 'title' => $this->l('This is the title'), 'icon' => 'icon-cogs' ), 'description' => $this->l('Here the description...'), 'input' => array( array( 'type' => 'switch', 'is_bool' => true, //retro-compat 'label' => $this->l('Enable'), 'name' => 'BTN_ENABLE_0', 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled') ) ), ), array( 'type' => 'select', 'lang' => true, 'label' => $this->l('Select an Option'), 'name' => 'SELECT_OPT', 'desc' => $this->l('Just select the option...'), 'options' => array( 'query' => $some_options, 'id' => 'id_option', 'name' => 'name' ) ), array( 'type' => 'text', 'label' => $this->l('Username'), 'name' => 'USERNAME', 'suffix' => 'USER', ), array( 'type' => 'text', 'label' => $this->l('Password'), 'name' => 'PASSWORD', 'suffix' => 'SECRET', ), array( 'type' => 'text', 'label' => $this->l('Some Code'), 'name' => 'SOME_CODE', 'suffix' => 'CODE', ), array( 'type' => 'desc', 'name' => '', 'text' => $this->l('And here another random text or whatever...') ), ), 'submit' => array( 'title' => $this->l('Save'), 'class' => 'btn btn-default pull-right' ) ), ); So I have this code and I want to show "Username" and "Password" fields only when I have "Option 1" selected and hide "Some Code" field. Then the oposite when "Option 2" is selected. Hide both "Username" and "Password" fields and show "Some Code" field. And that's it, I've already googled, searched here inside forum and just can't find the answer, which I believe to be something simple. Thank you very much in advance.
  7. For someone else in the future that might need this, it worked for me simplifying like this: if (!Db::getInstance()->execute('SELECT column_name from '._DB_PREFIX_.'table_name')) { Db::getInstance()->execute('ALTER TABLE '._DB_PREFIX_.'table_name ADD `column_name` char(32) NOT NULL DEFAULT ""'); }
  8. Thanks a lot for your answer. I don't know if this is true or not, but WOW! https://w3techs.com/technologies/details/cm-prestashop/1/all
  9. Thank you both for your inputs. Ok, so that means a lot of work and I will probably simply put this uncompatible with v1.4 1.4 market isn't that big, right?
  10. I appreciate your help and that's the very easy part. The hard part is figuring out how to make it work. I mean, I've tried to import HelperForm.php from 1.5 and other files as well but I couldn't make it work so I suppose there are other ways of doing it in 1.4 which are totally different from 1.5 and 1.6. This is my helperform by the way, how could I convert this to 1.4? $helper = new HelperForm(); $helper->show_toolbar = true; // false -> remove toolbar $helper->toolbar_scroll = true; // yes - > Toolbar is always visible on the top of the screen. $helper->toolbar_btn = array( 'save' => array( 'desc' => $this->l('Save'), 'href' => AdminController::$currentIndex.'&configure='.$this->name.'&save'.$this->name. '&token='.Tools::getAdminTokenLite('AdminModules'), ), 'back' => array( 'href' => AdminController::$currentIndex.'&token='.Tools::getAdminTokenLite('AdminModules'), 'desc' => $this->l('Back to list') ) ); $helper->table = $this->table; $helper->name_controller = $this->name; $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); $helper->default_form_language = $lang->id; $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; $helper->identifier = $this->identifier; $helper->override_folder = '/'; $helper->module = $this; $helper->submit_action = 'submitRemarketingEmailsSms'; $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->getConfigFieldsValues(), 'languages' => $this->context->controller->getLanguages(), 'id_language' => $this->context->language->id ); return $helper->generateForm(array( $fields_form_1, $fields_form_2, $fields_form_3, $fields_form_4, $fields_form_5, $fields_form_6, $fields_form_7, $fields_form_8, $fields_form_9, $fields_form_10, $fields_form_11, $fields_form_12, $fields_form_13 )); Thanks a lot in advance.
  11. Have you ever made this working? I have the very same situation as you and I am not being able to implement this. Can you help a little bit by explaining what you have done? Thanks a lot.
  12. First, let me thank you very much for your help. Actually, this module was developed by me and it has backward compability. What I can do is, I can check for Prestashop version and not insert that line for versions bellow 1.5. I have done that and then, a little more down on the code, there is an error on Shop::getContext on something I need to be shown. This is the line: if (Shop::getContext() === Shop::CONTEXT_SHOP) What do you say, can I simply remove this "if" when Prestashop version is belllow 1.5? Thanks a lot.
  13. Hi, Can someone help me figuring out why this error message appears on a Prestashop installation v1.4.8.2? Fatal error: Call to undefined method Shop::addSqlRestriction() in /home/www/modules/remarketing_emails_sms/remarketing_emails_sms.php on line 338 This is the code piece where, in the last line, this breaks: $sql = 'SELECT c.id_cart, c.id_lang, cu.id_customer, c.id_shop, cu.firstname, cu.lastname, cu.email FROM '._DB_PREFIX_.'cart c LEFT JOIN '._DB_PREFIX_.'orders o ON (o.id_cart = c.id_cart) LEFT JOIN '._DB_PREFIX_.'order_history oh ON (oh.id_order = o.id_order) RIGHT JOIN '._DB_PREFIX_.'customer cu ON (cu.id_customer = c.id_customer) RIGHT JOIN '._DB_PREFIX_.'cart_product cp ON (cp.id_cart = c.id_cart) WHERE DATE_SUB(CURDATE(),INTERVAL 90 DAY) <= c.date_add AND o.valid = 0 AND oh.id_order_state = "6"'; $sql .= Shop::addSqlRestriction(Shop::SHARE_CUSTOMER, 'c'); Any help will be much appreciated. Thanks a lot. Best regards, Pedro Lima
  14. Unbelievable that nobody has ever answered this! Could you solve this problem? I have a similar one as well.
  15. Thank you for your feedback. In that case, I left only Smarty active and changed as well File system to MySQL. What do you think of that?
  16. Smarty with File System, Eliminate everytime something is changed and Never compile theme files (already tried to change this option to Force compilation and didn't worked). Then, bellow, I also have activated Cache with File system. And that's it. Thanks.
  17. Hi, I cannot understand what's happening or causing this. I have deleted some categories and associated products to other categories. If I have cache disabled, everything works perfect but if I activate cache, it's a complete mess because if mixes products from other categories and some products doesn't even show. I had already cleared cache through backoffice, went directly to server and deleted cache/smarty/cache and cache/cachefs as well, everything was correctly rebuild but everything still the same... Has this problem ever happened to anyone? Runing v1.6.1.6 Thanks, Pedro Lima
  18. Well, I know how to complain so now I know how to praise your work. You did had a huge patience with this and the problem was, indeed, with our email because we were not receiving your attachment, although we receive others. Anyway, problem wolved so, once again, THANK YOU!
  19. I don't know what's happening, but now we do not receive any answer from you... we know that initially it was OUR fault and, once again, I am sorry for that because it was US that did not received your emails. But right now, we have the email working flawlessly, because we are receiving emails with no problems whatsoever, but no answer from you! As I stated in my email, we are losing a LOT of business because our customers cannot place any order for more than a week now, so this means an average loss of almost 2000€ for us... PLEASE, this is driving us crazy and all that we need is only that you send us one last time the module update, that's it! I won't be bothering you anymore... Thank you. Best regards, Pedro Lima
  20. I still haven't received any module yet since the last email sent to Cristina, could you please send it?
×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More