Create jQuery PopupBox, Cs-Cart Way

How to create a simple jquery popup window, following cs-cart style templates:


```php

click me



content here....


```

Bellow is how i have created my terms & conditions popup link, based on this code:

1. In backend, go to Administration / Languages : checkout_terms_n_conditions : and added the following variable translation value:
---
```php Select this check box to accept the
Terms and Conditions. ```
----

2. skins/[your_customer_selected_skin]/addons/my_changes/hooks/checkout/ create the file terms_and_conditions.override.tpl, with the bellow content:
```php
{include file="addons/my_changes/terms_and_conditions.tpl"}
```

3. Like you already guessed, now go to the root of my_changes dir, skins/[your_customer_selected_skin]/addons/my_changes/ and create the file: terms_and_conditions.tpl. Inside the file, put the following code:
```php
{$lang.checkout_terms_n_conditions}


{assign var=page_id value=2}

{if $page_id|fn_my_changes_terms_n_conditions}
{assign var="description" value=""|fn_my_changes_terms_n_conditions}
{$description|unescape}
{/if}


```

in my website, the terms and conditions page, has id=2. you can change it however you want/need

4. Clear the cache, in admin. Refresh the checkout page in storefront, and voila! Your popup window with terms and conditions!

Hope this will be helpful for other people who's looking for this type of mod.

Cheers,

Thanks, This is mucho useful

Hi!



I tried your mod, but i get this error:

Fatal error: Call to undefined function smarty_modifier_fn_my_changes_terms_n_conditions() in …customer/%%4D^4D7^4D74EBD7%%terms_and_conditions.override.tpl.php on line 15



Do you have any idea why i get this error?



Thanks

[quote name='robert_p' timestamp='1317990076' post='123121']

2. skins/[your_customer_selected_skin]/addons/my_changes/hooks/checkout/ create the file terms_and_conditions.override.tpl, with the bellow content:



3. Like you already guessed, now go to the root of my_changes dir, skins/[your_customer_selected_skin]/addons/my_changes/ and create the file: terms_and_conditions.tpl. Inside the file, put the following code:

[/quote]

I assume by “[your_customer_selected_skin]” in the filepath, you mean /skins/mythemename/customer/addons… etc? These folders do exist in my 2.2.3 install, but skins/mythemename/addons… etc does not exist.



I have created the appropriate files in the file paths I believe are correct and there is now a hyperlink created, but the link does not work as the source code reads:

```php


Select this check box to accept the Terms and Conditions.

```
I am not sure why this is not working correctly, the variables do not seem to be parsing their appropriate values, not sure if this is a limitation within CS-Cart 2.2.3 or another issue - any ideas?

Thank you

[quote name='jarody' timestamp='1318584866' post='123699']

Hi!



I tried your mod, but i get this error:

Fatal error: Call to undefined function smarty_modifier_fn_my_changes_terms_n_conditions() in …customer/%%4D^4D7^4D74EBD7%%terms_and_conditions.override.tpl.php on line 15



Do you have any idea why i get this error?



Thanks

[/quote]



Hi,



You need to create a function in cscart root folder / addons/my_changes/func.php. This is hte one used in my example:



function fn_my_changes_terms_n_conditions($page_id, $lang_code = CART_LANGUAGE){

$content = db_get_field("SELECT description FROM ?:page_descriptions WHERE lang_code = ?s AND page_id = ?i", $lang_code, $page_id);

$result = '

'.$content.'
';
echo $result;

}






and initiate it from init.php



fn_register_hooks(
'terms_n_conditions'
);




Sorry, I forgot to mentioned those 2.

[quote name='StellarBytes' timestamp='1320105487' post='125027']

I assume by “[your_customer_selected_skin]” in the filepath, you mean /skins/mythemename/customer/addons… etc? These folders do exist in my 2.2.3 install, but skins/mythemename/addons… etc does not exist.



I have created the appropriate files in the file paths I believe are correct and there is now a hyperlink created, but the link does not work as the source code reads:

```php


Select this check box to accept the Terms and Conditions.

```
I am not sure why this is not working correctly, the variables do not seem to be parsing their appropriate values, not sure if this is a limitation within CS-Cart 2.2.3 or another issue - any ideas?

Thank you
[/quote]


Hi,

Indeed, the link seems to not be parsed corectly (or some {, }, or {/if} are missing). I think i have removed theat part with {if} condition because, taking in consideration that will be a popup, i dont think i will ever need an url. So, you can remove that part, and everything should go fine.

[quote name='robert_p' timestamp='1320128980' post='125049']

Hi,



Indeed, the link seems to not be parsed corectly (or some {, }, or {/if} are missing). I think i have removed theat part with {if} condition because, taking in consideration that will be a popup, i dont think i will ever need an url. So, you can remove that part, and everything should go fine.

[/quote]

Thanks - I've tried again, still no joy. I took the {if} statement out, the variables ({$link_meta}) were still not parsed.

Select this check box to accept the Terms and Conditions.

I then tried no href at all, as I wasn't sure on your last instructions:

Select this check box to accept the Terms and Conditions.

This still doesn't work, I have used the code you originally posted for terms_and_conditions.tpl and terms_and_conditions.override.tpl - do I need to make any further edits?



Thanks again!

[quote name='StellarBytes' timestamp='1320141664' post='125059']

Thanks - I've tried again, still no joy. I took the {if} statement out, the variables ({$link_meta}) were still not parsed.

Select this check box to accept the Terms and Conditions.

I then tried no href at all, as I wasn't sure on your last instructions:

Select this check box to accept the Terms and Conditions.

This still doesn't work, I have used the code you originally posted for terms_and_conditions.tpl and terms_and_conditions.override.tpl - do I need to make any further edits?



Thanks again!

[/quote]



That's sad to hear:( Basically the principle, reduced, is this:

you have an a tag:


click me




and a div content tag, like:


```php


content here....

```

and that would be all.

the a tag must co-exist with the div tag in the same page. you can test using this simple way, then adjust to your needs.
maybe i have created confusion with the terms part ...

cheers,

Thanks, I found the label was generated in /skins/mytheme/customer/views/checkout/components/steps/step_four.tpl, so I placed the code in there for the label and the hidden div. Saved to the server, refreshed cache, and now I get the pop-up, but it displays this error:

Fatal error: Call to undefined function smarty_modifier_fn_my_changes_terms_n_conditions() in /home/cupargc/public_html/var/compiled/customer/%%29^294^294E560D%%step_four.tpl.php on line 436

I followed your advice previously, however, /addons/my_changes/func.php does not exist, when I create it and also make the init.php change, I get various errors displaying on the cart.



Any idea where this 'func.php' function should be created?

[quote name='StellarBytes' timestamp='1320172073' post='125088']

Thanks, I found the label was generated in /skins/mytheme/customer/views/checkout/components/steps/step_four.tpl, so I placed the code in there for the label and the hidden div. Saved to the server, refreshed cache, and now I get the pop-up, but it displays this error:

Fatal error: Call to undefined function smarty_modifier_fn_my_changes_terms_n_conditions() in /home/cupargc/public_html/var/compiled/customer/%%29^294^294E560D%%step_four.tpl.php on line 436

I followed your advice previously, however, /addons/my_changes/func.php does not exist, when I create it and also make the init.php change, I get various errors displaying on the cart.



Any idea where this 'func.php' function should be created?

[/quote]



in root folder of your cs cart, there is a directory called addons - this is the main addon directory; from here, all the addons in cs-cart are distributed;

ok, in root_cs_cart_folder/addons/my_changes/func.php

→ here you can create a lot of functions that enables you to do changes in cs-cart

then, create another file, called init.pht, in the same location with func.php

->from this file, you set the hooks for your functions created in my_changes, but without the preffix fn_my_changes_



be sure, that you have in admin backend / Administration / Addons / My changes installed/or enabled.

you can check my response to jarody, in order the see the lines from init,php and func.php

[quote name='robert_p' timestamp='1320172413' post='125092']

in root folder of your cs cart, there is a directory called addons - this is the main addon directory; from here, all the addons in cs-cart are distributed;

ok, in root_cs_cart_folder/addons/my_changes/func.php

→ here you can create a lot of functions that enables you to do changes in cs-cart

then, create another file, called init.pht, in the same location with func.php

->from this file, you set the hooks for your functions created in my_changes, but without the preffix fn_my_changes_



be sure, that you have in admin backend / Administration / Addons / My changes installed/or enabled.

you can check my response to jarody, in order the see the lines from init,php and func.php

[/quote]

I do have my_changes enabled, however, in /addons/my_changes/, there is definitely not a func.php or init.php in that folder. I am using CS Cart 2.2.3 - which version are you using? I can create these files, obviously, but when I do (pasting your code in), I am still left with this error in the pop-up window:


Fatal error: Call to undefined function smarty_modifier_fn_my_changes_terms_n_conditions() in /home/username/public_html/var/compiled/customer/%%29^294^294E560D%%step_four.tpl.php on line 436


Is the code you posted for func.php and init.php supposed to be the ONLY code in those files, or is there any additional code required?



Thanks again.

I finally got this working, however, one problem that has me totally stumped.



In /skins/mytheme/customer/addons/my_changes/terms_and_conditions.tpl I have “{assign var=page_id value=16}”, Page ID 16 being the page ID of my Terms page, as indicated by the URL when I edit the Terms page.



However, the terms pop-up in the checkout shows my 'About' page content, which has page ID 19.



I have cleared the cache using CS-Cart as well as manually, but no change - the wrong page ID's content is still shown.



Any idea why this might be happening? Thanks

Solved, I had put ‘terms_and_conditions.override.tpl’ in /skins/mytheme/customer/addons/my_changes/hooks/ - it should have been in a subfolder of ‘hooks’ called ‘checkout’ - because of this, I experienced the problems of variables not parsing their values. Now it all seems to work :D

I know this post is kind of getting old, but I just wanted to say thank you to Robert. This is a pretty sweet little mod. Thanks for putting this on here.



Brandon