Thread: Base Price

Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1
    Join Date
    Aug 2004
    Location
    Osaka Japan
    Posts
    163
    Plugin Contributions
    0

    Default Base Price

    The Base Price in the store in English is "Starting at" $00.00. In Japanese the order needs to be reversed to $00.00 "From" (yori). Is this possible?

  2. #2
    Join Date
    Jul 2012
    Posts
    16,742
    Plugin Contributions
    17

    Default Re: Base Price

    Quote Originally Posted by cjcraven View Post
    The Base Price in the store in English is "Starting at" $00.00. In Japanese the order needs to be reversed to $00.00 "From" (yori). Is this possible?
    Haven't looked at the area of the code, but generally speaking yes. If the line to be shown is setup to provide text with a variable substitution such as %d then the order of the variable could be moved around for each language in the language defines. That probably would end up being the easiest/most direct solution and may survive upgrading possibly easiest.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,577
    Plugin Contributions
    88

    Default Re: Base Price

    Quote Originally Posted by cjcraven View Post
    The Base Price in the store in English is "Starting at" $00.00. In Japanese the order needs to be reversed to $00.00 "From" (yori). Is this possible?
    Quote Originally Posted by mc12345678 View Post
    Haven't looked at the area of the code, but generally speaking yes. If the line to be shown is setup to provide text with a variable substitution such as %d then the order of the variable could be moved around for each language in the language defines. That probably would end up being the easiest/most direct solution and may survive upgrading possibly easiest.
    As mc12345678 indicated, it's possible and requires changes to two of your template-override files. I'm "assuming" that your main japanese language file is in /includes/languages/japanese.php, that your currently-selected template is named YOUR_TEMPLATE and that the products in your store are all of type 'Product-General' (which uses the product_info product type). Given those assumptions, you'll need to change two files:
    1. /includes/languages/YOUR_TEMPLATE/japanese.php. Locate the variable named TEXT_BASE_PRICE and change its definition to 'From (yori)'.
    2. /includes/templates/YOUR_TEMPLATE/templates/tpl_product_info_display.php. For v1.5.1, on line 70, change
      Code:
       echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') . zen_get_products_display_price((int)$_GET['products_id']);
      to
      Code:
       echo $one_time . zen_get_products_display_price((int)$_GET['products_id']) . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '');

  4. #4
    Join Date
    Jul 2012
    Posts
    16,742
    Plugin Contributions
    17

    Default Re: Base Price

    Well, my understandingof the situation was that there is one template, but that there was more than one language at play. In the one language the units prefaced the amount, in the other they were a suffix. What I was considering, and sorry for taking so long to provide more on what I was thinking, was that the define for the text: starting at: would include the appropriate symbol to provide the text for the cost. So that a sprintf() could be used in the template to feed the statement.

    So in english: the define would be something like 'Starting at: %s'
    And in Japanese it would be '%s yori'

    In both cases assuming that %s was the correct symbol to provide the cost with the units in the correct sequence and with the correct number of digits (a string).

    If the units are not attached to the cost value before sending to the above sprintf command, then the units could be fed to the command and for the approriate language they could be properly sequenced:
    English:define('STARTAT','starting at: %2$s%1$f');
    Sprintf(STARTAT,$cost,$symbol);
    Japanese: define('STARTAT','%1$f%2$s yuni');
    Sprintf(STARTAT,$cost,$symbol);

    This defines the variable STARTAT as the language defined variable that normally desplays the starting at text; however, the correct constant should be used in place of it. The sprintf command would be on the template wherever the current starting at text begins, the $cost variable would be the floating point value of the cost, although if the cost is already a string that includes the units then the define is simplified with just a %s and the call to the sprintf function would only have two arguments instead of three. (The first for the string to be displayed, the second for the first variable being substituted, and each subsequent being the next variable.) In the above example: %2$s means to use the second argument (in this case the third variable) in the sprintf and treat it as a string. %1$f means use the first argument (second variable) in the sprintf and treat it as a floating point.

    This way, the template will have one means of displaying the information, and it will be the language specific portion that will provide the formatting. This may be an issue for upgrading in the future, at least is something to consider when doing the upgrade. Item(s) affected:template, language files, potentially core like files depending on how implemented.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,577
    Plugin Contributions
    88

    Default Re: Base Price

    Good idea, mc12345678, perhaps it should be a suggestion for a future Zen Cart version! Good use of the $ modifier on the sprintf format, too (it's quite underused).

  6. #6
    Join Date
    Aug 2004
    Location
    Osaka Japan
    Posts
    163
    Plugin Contributions
    0

    Default Re: Base Price

    Thank you for your help. I will try the template modification lat9 suggested.

    Thank you mc12345678 for suggesting a more permanent solution, I hope the feature is added in future versions.

  7. #7
    Join Date
    Aug 2004
    Location
    Osaka Japan
    Posts
    163
    Plugin Contributions
    0

    Default Re: Base Price

    and shucks now I see that will become confusing to an English reader since the word order in English will be strange.

  8. #8
    Join Date
    Jul 2012
    Posts
    16,742
    Plugin Contributions
    17

    Default Re: Base Price

    Quote Originally Posted by cjcraven View Post
    and shucks now I see that will become confusing to an English reader since the word order in English will be strange.
    Code:
    echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') . zen_get_products_display_price((int)$_GET['products_id']);
    To:
    Code:
    echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? sprintf(TEXT_BASE_PRICE, zen_get_products_display_price((int)$_GET['products_id'])) : zen_get_products_display_price((int)$_GET['products_id']));
    And then also change the TEXT_BASE_PRICE for each language to use the %s where he price to appear: english at the end, japanese at the beginning.

    And that should do it for you I think. :) not tested, but also why I provided the version that I did, because japanese would need it at the beginning, but english (and probably some other languages) would need it at the end.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  9. #9
    Join Date
    Aug 2004
    Location
    Osaka Japan
    Posts
    163
    Plugin Contributions
    0

    Default Re: Base Price

    A solution is to change the English "$100 and up", not perfect but okay. Japanese is more finicky so the word order "$100 より" (yori) is perfect.

    Follow the steps explained by lat9

    Change two files:
    /includes/languages/YOUR_TEMPLATE/japanese.php. Locate the variable named TEXT_BASE_PRICE and change its definition to 'From ( yori)'.

    /includes/templates/YOUR_TEMPLATE/templates/tpl_product_info_display.php.

    Make the script changes to tpl_product_info_display.php.

  10. #10
    Join Date
    Jul 2012
    Posts
    16,742
    Plugin Contributions
    17

    Default Re: Base Price

    Quote Originally Posted by cjcraven View Post
    A solution is to change the English "$100 and up", not perfect but okay. Japanese is more finicky so the word order "$100 より" (yori) is perfect.

    Follow the steps explained by lat9

    Change two files:
    /includes/languages/YOUR_TEMPLATE/japanese.php. Locate the variable named TEXT_BASE_PRICE and change its definition to 'From ( yori)'.

    /includes/templates/YOUR_TEMPLATE/templates/tpl_product_info_display.php.

    Make the script changes to tpl_product_info_display.php.
    And you would have to make a similar language change as above for any/all other languages that would be used on that setup.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Price by attribute turned off but still adding base price
    By Rickk123 in forum Setting Up Categories, Products, Attributes
    Replies: 10
    Last Post: 26 Aug 2010, 11:19 PM
  2. Replies: 17
    Last Post: 21 Mar 2010, 05:57 PM
  3. Including Attribute Price Factor In Base Price Dropdown Menu
    By rob28870 in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 1 Oct 2008, 10:14 AM
  4. Base Price, then reduced price for additional quantities
    By leighbee in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 7
    Last Post: 30 Aug 2007, 01:17 AM
  5. Base price for product plus price by the foot?
    By kafer in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 19 Jan 2007, 12:17 AM

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