keat Posted April 26, 2018 Share Posted April 26, 2018 (edited) Under 'Store Settings' - 'Layout', I have 'disable show T&C's on checkout' unchecked. I have a document checked as T&C's, however, I don't see any T&C's on checkout. I'm using the Mican skin. Any pointers. edit: I also tried on a Foundation skin and connot see anything there either. Edited April 26, 2018 by keat Quote Link to comment Share on other sites More sharing options...
keat Posted April 27, 2018 Author Share Posted April 27, 2018 I found that if I register as a new customer, then T&C's box appears. If I log in, the T&C's doesn't show. I want the T&C's checkbox to appear with each order confirmation. I found the following line in content.checkout.confirm.php {if $TERMS_CONDITIONS} <div><label for="reg_terms"> </label><span><input type="checkbox" id="reg_terms" name="terms_agree" value="1" {$TERMS_CONDITIONS_CHECKED} /> <a href="{$TERMS_CONDITIONS}" target="_blank">{$LANG.account.register_terms_agree}</a></span></div> {/if} are there any changes I can make so have the T&C's box appear with each order confirmation. Quote Link to comment Share on other sites More sharing options...
bsmither Posted April 27, 2018 Share Posted April 27, 2018 Please try this. In admin, Manage Hooks, Code Snippets tab, click Add Snippet. Enabled: checked Unique ID: always_t&c@cubecart610+ Execution Order: 1 Description: Always show T&C Checkbox at Checkout Confirmation Trigger: class.cubecart.construct.confirm Version: 1.0 Author: https://forums.cubecart.com/topic/53903-tcs-not-showing/ PHP Code: <?php $GLOBALS['smarty']->assign('TERMS_CONDITIONS', (!$GLOBALS['config']->get('config', 'disable_checkout_terms') && $terms = $GLOBALS['db']->select('CubeCart_documents', false, array('doc_terms' => '1'))) ? $GLOBALS['seo']->buildURL('doc', $terms[0]['doc_id'], '&') : false); if (isset($_POST['terms_agree']) && $_POST['terms_agree']==1) { $this->_basket['terms_agree'] = true; } $GLOBALS['smarty']->assign('TERMS_CONDITIONS_CHECKED', (isset($this->_basket['terms_agree']) && $this->_basket['terms_agree']) ? 'checked="checked"' : ''); I did this a while ago, but I can't find the forum post that prompted me to write it. Quote Link to comment Share on other sites More sharing options...
keat Posted April 30, 2018 Author Share Posted April 30, 2018 (edited) Could there be something missing from the php code ? If I add the code as it is, then code sort of becomes corrupted, the code area fills with alpha numerical data. Thinking it may be missing an end statement, I added } ?> to the end, and this then causes a white screen. Tried this on another site, and again, the data becomes corrupted when I make the save. Edited April 30, 2018 by keat Quote Link to comment Share on other sites More sharing options...
bsmither Posted April 30, 2018 Share Posted April 30, 2018 If what you see is a hash of letters and numbers, then the code is getting converted to Base64, but not getting converted back to plain text when getting loaded into the editor. This leads me to believe that there is a mismatch in the code that runs this editor. Remind us the exact version of CubeCart you are running. Quote Link to comment Share on other sites More sharing options...
keat Posted May 1, 2018 Author Share Posted May 1, 2018 6.1.7 on both sites i tried. Quote Link to comment Share on other sites More sharing options...
bsmither Posted May 1, 2018 Share Posted May 1, 2018 (edited) Hmm. Using a database management utility, such as phpMyAdmin, look at the CubeCart_code_snippet table. Does the code column have contents that are a mix of hash and real PHP code? The hash would start with: PD9waH Edited May 1, 2018 by bsmither Quote Link to comment Share on other sites More sharing options...
keat Posted May 1, 2018 Author Share Posted May 1, 2018 (edited) I already looked in there and it shows 'Binary - Do Not Edit' and then all I get is a browse button which wants to open a local file. Edited May 1, 2018 by keat Quote Link to comment Share on other sites More sharing options...
bsmither Posted May 1, 2018 Share Posted May 1, 2018 Binary? That suggests the plain text code entered in the Code Snippet box is being base64 decoded into some unuseable stuff. I notice the snippet_id is '2'. What is at snippet_id is '1'? Quote Link to comment Share on other sites More sharing options...
keat Posted May 2, 2018 Author Share Posted May 2, 2018 I don't have any other snippet on that web site. Quote Link to comment Share on other sites More sharing options...
keat Posted May 3, 2018 Author Share Posted May 3, 2018 (edited) I found this thread. If I add: {if $TERMS_CONDITIONS} <div class="right"><span id="error_terms_agree"><input type="checkbox" id="reg_terms" name="terms_agree" value="1" {$TERMS_CONDITIONS_CHECKED} rel="error_terms_agree"><label for="reg_terms">{$LANG.account.register_terms_agree_link|replace:'%s':{$TERMS_CONDITIONS}}</label></span></div> {/if} to content.checkout.php, nothing appears. I remove the two 'If statements, and now the box appears. However, I can proceed without checking the box and when I click on the hyperlink for T&C's it loops me back to the confirm page. www.latexglovesonline.co.uk Edited May 3, 2018 by keat Quote Link to comment Share on other sites More sharing options...
keat Posted May 9, 2018 Author Share Posted May 9, 2018 Guys I could really do with this to comply with GDPR, so if anyone could shed any light how I would enforce T&C's with each order, i'd very much appreciate any help. At least until i can consider any CC software updates. Adding <div class="right"><span id="error_terms_agree"><input type="checkbox" id="reg_terms" name="terms_agree" value="1" {$TERMS_CONDITIONS_CHECKED} rel="error_terms_agree"><label for="reg_terms">{$LANG.account.register_terms_agree_link|replace:'%s':{$TERMS_CONDITIONS}}</label></span></div> to contecnt.checkout.php half does the job,. I just could do with some help making the checkbox enforceable and a link to my T&C's pages working. If this means encoding the actual URL it will suffice. Quote Link to comment Share on other sites More sharing options...
bsmither Posted May 9, 2018 Share Posted May 9, 2018 Please review: https://github.com/cubecart/v6/commit/61b7720ee08d020e531de6464d23b32757f83113 Verify if the statements in your installation match these changes (which were implemented in CC614). With respect to: {if $TERMS_CONDITIONS} <div class="right"><span id="error_terms_agree"><input type="checkbox" id="reg_terms" name="terms_agree" value="1" {$TERMS_CONDITIONS_CHECKED} rel="error_terms_agree"><label for="reg_terms">{$LANG.account.register_terms_agree_link|replace:'%s':{$TERMS_CONDITIONS}}</label></span></div> {/if} Try: {if true || $TERMS_CONDITIONS} <div class="right"><span id="error_terms_agree"><input type="checkbox" id="reg_terms" name="terms_agree" value="1" rel="error_terms_agree"><label for="reg_terms">{$LANG.account.register_terms_agree_link|replace:'%s':"{$STORE_URL}/friendly_path_to_t&c_doc.html"}</label></span></div> {/if} Quote Link to comment Share on other sites More sharing options...
bsmither Posted May 9, 2018 Share Posted May 9, 2018 (edited) Actually, let's try adding the PHP code directly where the hook is. So, in /classes/cubecart.class.php: Find: private function _checkout() About 15 lines later, find: foreach ($GLOBALS['hooks']->load('class.cubecart.construct.confirm') as $hook) include $hook; On a new blank line after that, add: $GLOBALS['smarty']->assign('TERMS_CONDITIONS', (!$GLOBALS['config']->get('config', 'disable_checkout_terms') && $terms = $GLOBALS['db']->select('CubeCart_documents', false, array('doc_terms' => '1'))) ? $GLOBALS['seo']->buildURL('doc', $terms[0]['doc_id'], '&') : false); if (isset($_POST['terms_agree']) && $_POST['terms_agree']==1) { $this->_basket['terms_agree'] = true; } $GLOBALS['smarty']->assign('TERMS_CONDITIONS_CHECKED', (isset($this->_basket['terms_agree']) && $this->_basket['terms_agree']) ? 'checked="checked"' : '' ); Edited May 15, 2018 by bsmither Quote Link to comment Share on other sites More sharing options...
keat Posted May 10, 2018 Author Share Posted May 10, 2018 (edited) I tried adding the lines to cubecart.class.php, but the page seems to hang with just a white screen. No errors are produced in error.log. I then went up to the suggestion above that comment and added: {if true || $TERMS_CONDITIONS} <div class="right"><span id="error_terms_agree"><input type="checkbox" id="reg_terms" name="terms_agree" value="1" rel="error_terms_agree"><label for="reg_terms">{$LANG.account.register_terms_agree_link|replace:'%s':"{$STORE_URL}/friendly_path_to_t&c_doc.html"}</label></span></div> {/if} to content.checkout.php. I can now get the link to open T&C's, but can still proceed to checkout without having to check the agree button. Edited May 10, 2018 by keat Quote Link to comment Share on other sites More sharing options...
bsmither Posted May 10, 2018 Share Posted May 10, 2018 When I copy-pasted the snippet code above, I missed copying the very last semi-colon. I ask that you try again. Quote Link to comment Share on other sites More sharing options...
keat Posted May 11, 2018 Author Share Posted May 11, 2018 I still get a blank screen. Quote Link to comment Share on other sites More sharing options...
bsmither Posted May 11, 2018 Share Posted May 11, 2018 (edited) Let's try creating the error_log. But you say you already have an error_log. Anything new in it? You will also get a blank screen if there is a problem with Smarty code in the template. Finding those errors can be rough. They sometimes show up in the admin, System Error Logs. Edited May 11, 2018 by bsmither Quote Link to comment Share on other sites More sharing options...
keat Posted May 15, 2018 Author Share Posted May 15, 2018 (edited) error log inside the cart shows [Exception] /home/xxxxxxx/public_html/classes/cubecart.class.php:910 - syntax error, unexpected ';', expecting ',' or ')' If I modify the end of the last line to : ''); I get this. [Exception] /home/xxxxxxxx/public_html/classes/cubecart.class.php:906 - Call to a member function assign() on string Although i don't understand PHP so it would be no surprise that i did wrong. Edited May 15, 2018 by keat Quote Link to comment Share on other sites More sharing options...
bsmither Posted May 15, 2018 Share Posted May 15, 2018 Working on the assumption the version of PHP you are running, I've adjusted the code just a bit. Try: $GLOBALS['smarty']->assign('TERMS_CONDITIONS', (!$GLOBALS['config']->get('config', 'disable_checkout_terms') && (($terms = $GLOBALS['db']->select('CubeCart_documents', false, array('doc_terms' => '1'))) !== false)) ? $GLOBALS['seo']->buildURL('doc', $terms[0]['doc_id'], '&') : false); if (isset($_POST['terms_agree']) && $_POST['terms_agree']==1) {$this->_basket['terms_agree'] = true;} $GLOBALS['smarty']->assign('TERMS_CONDITIONS_CHECKED', (isset($this->_basket['terms_agree']) && $this->_basket['terms_agree']) ? 'checked="checked"' : '' ); Quote Link to comment Share on other sites More sharing options...
keat Posted May 16, 2018 Author Share Posted May 16, 2018 I now no longer get the white screen. However, I don't see the t&C's checkbox either. PHP Version 7.0.30 by the way Quote Link to comment Share on other sites More sharing options...
bsmither Posted May 16, 2018 Share Posted May 16, 2018 Open the skin template main.php for editing. At the every end, add {debug}. Visit the page where you expect the T&C checkbox to be. The browser will want to toss up a popup window. Let it. (You may need to refresh the page.) You can now remove the {debug} from the template. In the popup, in the left pane, scroll to $TERMS_CONDITIONS. Verify there is a web address as its value. Quote Link to comment Share on other sites More sharing options...
keat Posted May 17, 2018 Author Share Posted May 17, 2018 (edited) $TERMS_CONDITIONS Origin: "Smarty object" Value "https://www.xxxxxxxx.co.uk/terms-conditions.html" $TERMS_CONDITIONS_CHECKED Origin: "Smarty object" Value "" Do I need to add anything to content.checkout.php to make it appear. All I have at the moment is the edit to cubecart.class Edited May 17, 2018 by keat Quote Link to comment Share on other sites More sharing options...
bsmither Posted May 17, 2018 Share Posted May 17, 2018 As seen in the code shown in the second post, {if $TERMS_CONDITIONS} being true-like, the HTML for the checkbox will get included in the page. Have your browser show you the page's HTML source. You should be able to find the checkbox. Quote Link to comment Share on other sites More sharing options...
keat Posted May 18, 2018 Author Share Posted May 18, 2018 I'm confused. In content.checkout.confirm.php I see: {if $TERMS_CONDITIONS} <div><label for="reg_terms"> </label><span><input type="checkbox" id="reg_terms" name="terms_agree" value="1" {$TERMS_CONDITIONS_CHECKED} /> <a href="{$TERMS_CONDITIONS}" target="_blank">{$LANG.account.register_terms_agree}</a></span></div> {/if} But when I view the page source I see no reference to terms other than the site links which appear at the bottom of the page. I don't see the checkbox anywhere. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.