Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,585
    Plugin Contributions
    30

    Default Forcing a script to use constants from a specific language

    I'm writing an automailer to send emails some time after an order.

    I am trying to build the email content in the language that the order was made in, using extra constants defined for that purpose.

    My problem is forcing the script (which uses application_top) to use the correct language constants on demand.

    Normally the constants used are always those of the currently-selected shop language (when it is open in other tab of the browser).

    Hard-coding in the script the SESSION values for language, languages_id and code works in isolation...
    eg:
    1) if script session values are set to language 1, script uses constants from language 1
    2) when the shop tab is changed to language 2, the next time the script is refreshed it uses language 2, then the second time it is refreshed it reverts to language 1 as required

    I understand its a session issue, but I would like some confirmation that
    a) this is impossible when there is an active session in the same browser
    b) if the script is run as a cron job, this will not be an issue

    I've done a lot of playing around and in any case would still like to know if it is possible to force the use of a specific language by a script irrespective of other browser sessions.
    Steve
    github.com/torvista: Spanish Language Pack, Google reCaptcha, Structured Data, Multiple Copy-Move-Delete, Image Checker, BackupMySQL Admin/Auto...

  2. #2
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,585
    Plugin Contributions
    30

    Default Re: Forcing a script to use constants from a specific language

    I suppose I could use four cron jobs in sequence:
    first one sets the session language, second runs the script,
    third changes the language, fourth runs the script?
    Steve
    github.com/torvista: Spanish Language Pack, Google reCaptcha, Structured Data, Multiple Copy-Move-Delete, Image Checker, BackupMySQL Admin/Auto...

  3. #3
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Forcing a script to use constants from a specific language

    I'm trying to figure out to/from what "event" you are capturing the SESSIONS language. It would seem to me, that if you are talking about sending a message to a customer at a point when they are no longer on your system, then the language used/preferred by the customer should be captured/maintained for use by the auto emailer. (Ie an additional field in a customer related table.) That way regardless of a few second delay or a few months delay the preference is known. (This is assuming that there is not already a preferred language captured in the table. Of course the easy way outis to have as many languages in the message as your store holds, but... That's also the easy way out.

    So my thought is, upon sending the "message" it seems that it would not matter what the current language was, because that captured data would be what provides the data to be sent via email.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  4. #4
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,585
    Plugin Contributions
    30

    Default Re: Forcing a script to use constants from a specific language

    Yes its a bit hard to explain...I do record the language used with every order rather than as a customer preference, so that info is available for retrieval.

    I am sending an email a couple of weeks later to remind them to post a review, so I want the text in that email to use the correct language by pulling in defined text from language files.
    I could have just hard-coded it in the script instead but I am trying to make it as flexible as possible for a future contribution.

    At the minute I am calling a preliminary script with the cron: "autoemailer_cron.php?lang=es" which sets the session variables then redirects to the full script "autoemailer.php". That is working ok now irrespective of other sessions in the same browser.
    Steve
    github.com/torvista: Spanish Language Pack, Google reCaptcha, Structured Data, Multiple Copy-Move-Delete, Image Checker, BackupMySQL Admin/Auto...

 

 

Similar Threads

  1. v154 controlling/forcing session language
    By torvista in forum General Questions
    Replies: 5
    Last Post: 19 Mar 2015, 04:07 PM
  2. Replies: 0
    Last Post: 17 Jul 2014, 08:17 AM
  3. List constants from a specific language file?
    By torvista in forum General Questions
    Replies: 3
    Last Post: 8 Jul 2011, 08:15 PM
  4. How to enable to use PayPal to process orders from specific geographic region?
    By jottoleivi in forum PayPal Express Checkout support
    Replies: 1
    Last Post: 16 Jan 2008, 09:08 PM
  5. Updating Language constants dynamically
    By coldasice1234 in forum Basic Configuration
    Replies: 12
    Last Post: 6 Sep 2007, 09:15 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR