Neuigkeiten
  • Die modified eCommerce Shopsoftware ist kostenlos, aber nicht umsonst.
    Spenden
  • Damit wir die modified eCommerce Shopsoftware auch zukünftig kostenlos anbieten können:
    Spenden
  • Thema: About 'Smarty' variable, how to handle it

    DyO13

    • Neu im Forum
    • Beiträge: 20
    About 'Smarty' variable, how to handle it
    am: 22. Mai 2015, 11:27:26
    Hello everyone, im having a problem with a 'Smarty' variable.

    I should say that in the shop im currently working, we sells books, audio-cd's, etc. And there is an option for the audios to get downloaded for a minor price or less points (we use a bonuspoints system).

    So in the templates/modules/product_options, i've seen that on products_options_selections_html, there is an input, that shows all the selections, and each item is sorted by values, e.G

    Code: PHP  [Auswählen]
     {foreach key=key_data name=key_data item=item_data from=$options_data.DATA}
     
      <input type="radio" name="id[{$options_data.ID}]" value="{$item_data.ID}" {if $smarty.foreach.key_data.first} checked {/if} />
        {$item_data.TEXT} {if $item_data.PRICE!=''}( {$item_data.PREFIX}{$item_data.PRICE} ){/if}
        <br />
        {/foreach}

    What i desperate want, is to know how is value="{$item_data.ID}" handled. Im sure that this variable comes from products_attributes.php on 'includes/modules', the ID i mean.

    My purpose on knowing this is to relate the value with a specific cart submit.

    e.G

    Instead of clicking the second 'item' of the input to add it to the shoppingcart, i just want to click on a button i already made in products_info.php which will directly "pick" that option for me and add it to the shopping cart.

    Im pretty sure that "all i need to do" is to somehow set the "{$item_data.ID}" variable on the .php file (or even .html part if possible through Smarty) where the button i already implemented is

    How is this possible? or maybe i should do it on cart_actions.php? (here i put a new "submit_to_cart" script for buying with bonuspoints

    Can it be possible to set the variable from another file which is not product_attributes.php to make it happen, like in product_info.php?

    I'll attach a pic.


    Note: I wouldn't be asking here if i haven't been spending so much time looking for it. Thanks in advance

    Linkback: https://www.modified-shop.org/forum/index.php?topic=33029.0
    Managed Server

    noRiddle (revilonetz)

    • Experte
    • Beiträge: 13.988
    • Geschlecht:
    Re: About 'Smarty' variable, how to handle it
    Antwort #1 am: 23. Mai 2015, 18:22:16
    What argues against a javascript routine ?
    Write a short function with the help of jQuery (I suppose you have jQuery implemented anyway like it is per default) which checks the respective radio button and assign the function to the button via onclick="YOUR_FUNCTION()".

    Since we don't know exactly which processes will be launched when clicking that download button I don't have a better idea so far.

    *EDIT*
    On the other hand /includes/cart_actions.php should be the right place to handle your demands via php by setting the $_POST['id'] (which is the option choosen) may be hard-coded, insofar as it is always the same id.

    Cheers,
    noRiddle

    DyO13

    • Neu im Forum
    • Beiträge: 20
    Re: About 'Smarty' variable, how to handle it
    Antwort #2 am: 26. Mai 2015, 09:18:54
    What argues against a javascript routine ?
    Write a short function with the help of jQuery (I suppose you have jQuery implemented anyway like it is per default) which checks the respective radio button and assign the function to the button via onclick="YOUR_FUNCTION()".

    Since we don't know exactly which processes will be launched when clicking that download button I don't have a better idea so far.

    *EDIT*
    On the other hand /includes/cart_actions.php should be the right place to handle your demands via php by setting the $_POST['id'] (which is the option choosen) may be hard-coded, insofar as it is always the same id.

    Cheers,
    noRiddle

    Thanks a lot! I've been trying before with the $_POST['id'], but i was not getting any result, so i though i wasn't the way of how to do it. But now that you confirm it, i was totally sure, and i could finally do it.
    Really big thanks for the help, im so grateful for real. Have a nice day!  :-D
    Werbung / Banner buchen
    9 Antworten
    5328 Aufrufe
    02. April 2016, 20:48:06 von WayneTsun
    1 Antworten
    2382 Aufrufe
    09. Dezember 2015, 16:42:31 von ShopUser
    1 Antworten
    1894 Aufrufe
    26. November 2014, 06:16:45 von hendrik
    12 Antworten
    783 Aufrufe
    17. Januar 2024, 09:20:42 von je_web
               
    anything