Home Forums WoodMart support forum Fatal ArgumentCountError in custom sale percentage label with Arabic translation

Fatal ArgumentCountError in custom sale percentage label with Arabic translation

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #724645

    moatasemco
    Participant

    Hello WoodMart Support Team,

    I am experiencing a fatal error in the WoodMart custom product sale-label module when the website language is Arabic.

    ### Fatal error

    `text
    Fatal error: Uncaught ArgumentCountError: 3 arguments are required, 2 given
    `

    The error occurs here:

    `text
    wp-content/themes/woodmart/inc/integrations/woocommerce/modules/custom-labels/class-frontend.php:133
    `

    The relevant call shown in the stack trace is:

    `php
    sprintf(‘-%d%’, 30.0)
    `

    ### Expected value

    The format string should be:

    `php
    sprintf(‘-%d%%’, 30.0)
    `

    which outputs:

    `text
    -30%
    `

    ### Actual problem

    The sale-percentage translation appears to return:

    `text
    -%d%
    `

    instead of:

    `text
    -%d%%
    `

    Because the final percentage sign is not escaped, PHP interprets it as another formatting placeholder and throws an ArgumentCountError.

    ### Steps to reproduce

    1. Set the WordPress site language to Arabic.
    2. Enable percentage sale labels in WoodMart.
    3. Add a sale price to a product, including a variable product.
    4. Display the product through a WoodMart Products Gutenberg block or shop product loop.
    5. The page crashes while rendering the sale label.

    The error disappears when the percentage-label feature is disabled or when the translated format is corrected from:

    `text
    -%d%
    `

    to:

    `text
    -%d%%
    `

    ### Environment

    * WoodMart version: [INSERT VERSION]
    * WoodMart Core version: [INSERT VERSION]
    * WordPress version: [INSERT VERSION]
    * WooCommerce version: [INSERT VERSION]
    * PHP version: [INSERT VERSION]
    * Website language: Arabic
    * Translation method: [WoodMart language pack / Loco Translate / WPML / other]

    Could you please check the official Arabic translation for the string with context:

    `text
    sale percentage
    `

    Original string:

    `text
    -%d%%
    `

    It may also be useful to validate translated sprintf() strings before passing them to PHP, so a malformed translation cannot cause a fatal frontend error.

    Thank you.

    Wordpress version: 7.0.2
    Woocommerce: 10.9.4
    Woodmart Core: 1.1.8
    Woodmart theme: 8.5.7

    #724652

    Serg Sokhatskyi
    Keymaster
    Xtemos team

    Hi there,

    Thanks for the detailed report and for pinpointing the sprintf format issue.

    You’re right — this was caused by an error in our Arabic translation for the sale percentage label. We’ve fixed the translation and updated the language files on our server, and a patch has been released for this (ID: #724642).

    Please update to the latest WoodMart/WoodMart Core and refresh your Arabic translation files to pull the fix. After updating, the format will be “-%d%%” and the fatal error should be resolved.

    Kind regards,
    XTemos Studio

Viewing 2 posts - 1 through 2 (of 2 total)