DomsAdmin Posted March 11, 2012 Share Posted March 11, 2012 Soheil: Good Day! Thank you for your interest in my coding issue. Shokino provided me with the code below for adding the checkout button to the blockuserinfo module which I would like to only displays once item(s) are added to the cart. The issue is that I don't have any idea on how and just where to place the code below and if there is anything else to add to this code for it to work correctly...If possible please help with suggestions. Thanks for all of your timely additions to the forum! Domsadmin 1. you need assign smarty variable in the module PHP file $smarty->assign('numberOfProducts', $cart->nbProducts()); 2. Then use this variable in tpl file {if $numberOfProducts > 0} ........ {/if} Link to comment Share on other sites More sharing options...
bellini13 Posted March 11, 2012 Share Posted March 11, 2012 you would edit the modules\blockuserinfo\blockuserinfo.tpl template, and add the "if" statement where ever you want the add button to appear. no need to add the other smarty assign. the blockuserinfo module already does this 'cart_qties' => $cart->nbProducts(), just change you if statement to {if $cart_qties > 0} 1 Link to comment Share on other sites More sharing options...
DomsAdmin Posted March 12, 2012 Author Share Posted March 12, 2012 Bellini13: Thank you for the suggestion. However what I am trying to do is have the actual button hidden when there aren't any products in the cart and to only display when products are placed into the cart. The code below is already part of my blockuserinfo.tpl file: 'cart_qties' => $cart->nbProducts(), just change you if statement to {if $cart_qties > 0} Any suggestions? Link to comment Share on other sites More sharing options...
bellini13 Posted March 12, 2012 Share Posted March 12, 2012 so put the button code inside the if statement as DomsAdmin already stated above. I was just informing you that a variable for the number of products already existed. Link to comment Share on other sites More sharing options...
DomsAdmin Posted March 12, 2012 Author Share Posted March 12, 2012 Thanks, amazing suggestion Bellini13! Is it possible if you can please explain how I would put the button code inside the if statement? Here is the button code below from the blockcart module: -Button Code- <a href="{$link->getPageLink("$order_process.php", true)}{if $order_process == 'order'}?step=1{/if}" id="button_order_cart" class="button_small" title="{l s='Check out' mod='blockcart'}">{l s='Check out' mod='blockcart'}</a> -Here is the section of the blockuserinfo.tpl code that I believe the button code should go: <span class="ajax_cart_quantity{if $cart_qties == 0} hidden{/if}">{$cart_qties}</span> <span class="ajax_cart_product_txt{if $cart_qties != 1} hidden{/if}">{l s='product' mod='blockuserinfo'}</span> <span class="ajax_cart_product_txt_s{if $cart_qties < 2} hidden{/if}">{l s='products' mod='blockuserinfo'}</span> <span class="ajax_cart_no_product{if $cart_qties > 0} hidden{/if}">{l s='(empty)' mod='blockuserinfo'}</span> The question is (if this is the correct section of blockuserinfo.tpl code) is where and how to place the button code? Link to comment Share on other sites More sharing options...
bellini13 Posted March 13, 2012 Share Posted March 13, 2012 i can't tell you where to place the button, where ever you decide to place the button, it would look like this. {if $cart_qties > 0} <a href="{$link->getPageLink("$order_process.php", true)}{if $order_process == 'order'}?step=1{/if}" id="button_order_cart" class="button_small" title="{l s='Check out' mod='blockcart'}">{l s='Check out' mod='blockcart'}</a> {/if} 1 Link to comment Share on other sites More sharing options...
DomsAdmin Posted March 13, 2012 Author Share Posted March 13, 2012 Bellini13 The suggestion works! However when the item(s) are placed into cart the checkout button appears and the page is automatically directed to the checkout page. Is there any way to make the checkout button appear and only direct you to the checkout page after the button is pressed when ready to proceed with checkout? Link to comment Share on other sites More sharing options...
bellini13 Posted March 13, 2012 Share Posted March 13, 2012 confirm your product settings. go into the back office, go to the preferences | products section. scroll down and locate the "Re-direction after adding product to cart" option. change it to "previous page" also ,do you know if you have the ajax cart setting enabled? 2 Link to comment Share on other sites More sharing options...
DomsAdmin Posted March 13, 2012 Author Share Posted March 13, 2012 Good day! I I am running prestashop 1.4.7, where would the ajax cart function be located? Link to comment Share on other sites More sharing options...
bellini13 Posted March 14, 2012 Share Posted March 14, 2012 look in the blockcart module configuration. Link to comment Share on other sites More sharing options...
DomsAdmin Posted March 14, 2012 Author Share Posted March 14, 2012 I just confirmed my settings. I am running my cart with ajax enabled. I noticed that it says that the "previous page" redirection is only available on the non-ajax cart. Is there a way around this if I would still like to use the ajax enabled cart? Link to comment Share on other sites More sharing options...
bellini13 Posted March 14, 2012 Share Posted March 14, 2012 if you are using ajax, then when you add a product to the cart, you should not be navigating to a new page. Link to comment Share on other sites More sharing options...
DomsAdmin Posted March 15, 2012 Author Share Posted March 15, 2012 We're getting closer, thanks! That last suggestion seems to work, however when I empty the shopping cart the checkout button doesn't disappear and I also noticed that sometimes when I add product(s) to the shopping cart the checkout button doesn't appear for certain products. Any suggestions on how to remedy these issues? Link to comment Share on other sites More sharing options...
bellini13 Posted March 15, 2012 Share Posted March 15, 2012 if the page is not refreshing, then the information in your userinfo block is also not refreshing. you would have to use jquery or scripting to show/hide your button after an action is performed on the cart. Link to comment Share on other sites More sharing options...
DomsAdmin Posted March 15, 2012 Author Share Posted March 15, 2012 That's very interesting! Do you have any suggestions on how this can be done using jquery or some type of scripting? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now