Discount Codes

A little jquery in version 6.1 - Discount Codes

A little jquery in version 6.1

by frankl » Wed Jul 02, 2025 5:34 am

admin\includes\actions\discount_codes\views\new.php

Nothing serious:

Code: Select all

<script>
$(document).ready(function() {
    if (<?= ((isset($action) && $action == 'new') ? 'true' : 'false')?>) {
        onload();
    }
});
function applies_to_onclick() {
  var a = document.new_discount_code.applies_to, b = document.getElementById("excluded_products_id"), c = document.getElementById("number_of_products"), d = document.getElementById("exclude_specials"), e = document.getElementById("products_id"), f = document.getElementById("categories_id"), g = document.getElementById("manufacturers_id");
  for (var i = 0, n = a.length; i < n; i++) if (a[i].checked) { b.disabled = (a[i].value == 2 || a[i].value == 4 ? false : true); c.disabled = (a[i].value == 3 || a[i].value == 5 || a[i].value == 6 ? true : false); d.disabled = (a[i].value == 3 || a[i].value == 6 ? true : false); e.disabled = (a[i].value == 1 ? false : true); f.disabled = (a[i].value == 2 ? false : true); g.disabled = (a[i].value == 4 ? false : true) }
  }
function customers_onclick() {
  var d = document.getElementById("customers"), e = document.getElementById("customers_id"); e.disabled = !d.checked;
}
function onload() {
  applies_to_onclick();
  customers_onclick();
}
$('#expires_date').datepicker({
  dateFormat: 'yy-mm-dd'
});
</script>
Can be changed to:

Code: Select all

<script>
document.addEventListener('DOMContentLoaded', function () {
  const actionIsNew = <?= ((isset($action) && $action == 'new') ? 'true' : 'false') ?>;
  if (actionIsNew) {
    onload();
  }
});

function applies_to_onclick() {
  const form = document.forms['new_discount_code'];
  const applies_to = form?.elements['applies_to'];
  const excluded_products_id = document.getElementById("excluded_products_id");
  const number_of_products = document.getElementById("number_of_products");
  const exclude_specials = document.getElementById("exclude_specials");
  const products_id = document.getElementById("products_id");
  const categories_id = document.getElementById("categories_id");
  const manufacturers_id = document.getElementById("manufacturers_id");

  if (!applies_to) return;

  for (let i = 0; i < applies_to.length; i++) {
    if (applies_to[i].checked) {
      const val = parseInt(applies_to[i].value, 10);
      excluded_products_id.disabled = !(val === 2 || val === 4);
      number_of_products.disabled = (val === 3 || val === 5 || val === 6);
      exclude_specials.disabled = (val === 3 || val === 6);
      products_id.disabled = (val !== 1);
      categories_id.disabled = (val !== 2);
      manufacturers_id.disabled = (val !== 4);
      break;
    }
  }
}

function customers_onclick() {
  const customers = document.getElementById("customers");
  const customers_id = document.getElementById("customers_id");
  if (customers && customers_id) {
    customers_id.disabled = !customers.checked;
  }
}

function onload() {
  applies_to_onclick();
  customers_onclick();
}
</script>

and line 115 changed from

Code: Select all

<div class="col-sm-6"><?= new Input('expires_date', ['value' => $dInfo->expires_date, 'min' => date('Y-m-d'), 'id' => 'expires_date', 'style' => 'width: 150px;', 'onfocus' => 'this.showPicker?.()'], 'date') ?>
to

Code: Select all

<div class="col-sm-6"><?= new Input('expires_date', ['value' => $dInfo->expires_date, 'min' => date('Y-m-d'), 'id' => 'expires_date', 'style' => 'width: 150px;'], 'date') ?>
Also line 133 from

Code: Select all

<div class="col-sm-6"><?= new Input('order_number', ['value' => $dInfo->order_number, 'id' => 'order_number', 'style' => 'width: 50px;']) ?>
to

Code: Select all

<div class="col-sm-6"><?= new Input('order_number', ['value' => $dInfo->order_number, 'id' => 'order_number', 'style' => 'width: 150px;']) ?>
to match other field sizes.
frankl
Builder
Posts: 159
Joined: Tue Feb 23, 2021 8:39 pm
Phoenix Version: v1.1.0.4
Contact:

Re: A little jquery in version 6.1

by raiwa » Wed Jul 02, 2025 7:10 am

Thank you, I’ll update.
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
raiwa
Certified Developer
Posts: 1640
Joined: Sat Dec 21, 2019 8:08 am
Phoenix Version: 1.1.0.6
Contact:

Re: A little jquery in version 6.1

by Scratchilito » Fri Jan 16, 2026 7:58 am

Hello,

Does version 6.2 only concern this file: admin\includes\actions\discount_codes\views\new.php?

This confirmation would save me from having to re-translate all the other files unnecessarily.

I think that in your: Discount_Codes_Phoenix_upgrade_manual.txt file, you could indicate for future updates which files have been modified from one increment to the next.
Scratchilito
Member
Posts: 37
Joined: Wed Jan 26, 2022 2:15 pm
Phoenix Version: v1.1.0.6
Contact:

Re: A little jquery in version 6.1

by raiwa » Fri Jan 16, 2026 8:26 am

Hi,
The only change is in:
includes\modules\order_total\ot_discount.php

The version and date references in the file headers are updated in all files. Thats why the update says replace all files.

I do not understand what you need to retranslate.
Anyway you can use a file comparing tool like WinMerge to find the differences.
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
raiwa
Certified Developer
Posts: 1640
Joined: Sat Dec 21, 2019 8:08 am
Phoenix Version: 1.1.0.6
Contact:

Re: A little jquery in version 6.1

by Scratchilito » Fri Jan 16, 2026 9:25 am

raiwa wrote: ...I do not understand what you need to retranslate.
Anyway you can use a file comparing tool like WinMerge to find the differences.
Thank you for your reply.

You provide this add-on in English, Spanish and German, and I add French, which is my language of choice. This therefore concerns the admin and public sections.
I also translate a very small part of /includes/modules/*.php simply for the installation and management part in the administration interface.

In fact, I do this for all the add-ons that I activate in my shop. ;)
Scratchilito
Member
Posts: 37
Joined: Wed Jan 26, 2022 2:15 pm
Phoenix Version: v1.1.0.6
Contact:

Re: A little jquery in version 6.1

by raiwa » Fri Jan 16, 2026 10:24 am

Your french language files will not be overwritten. The other translations are your choice. The configuration text should not be translated.
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
raiwa
Certified Developer
Posts: 1640
Joined: Sat Dec 21, 2019 8:08 am
Phoenix Version: 1.1.0.6
Contact: