Rhobur Posted April 3, 2016 Share Posted April 3, 2016 Hi, I am stuck at this point. I have a select added to product-list and a resulting jquery selected option variable. I need to add it to the ajax cart in order to see what the client selected, no price influence yet just a simple display. I can POST this variable, can catch it in a php variable but cannot neither assign it to another Smarty variable nor make a direct Smarty assignment through $_POST or $smarty.post. Trying that results in a blank page and a console error "Post 500 (Internal Server Error)" Can someone enlighten me of how I can see the variable content in the ajax cart? Or at least give me some pointers? I have looked all over and found nothing useful. Have a great week, all! R. Link to comment Share on other sites More sharing options...
shacker Posted April 14, 2016 Share Posted April 14, 2016 hi. In wich place you put the code?you want to show in shopping cart module? Link to comment Share on other sites More sharing options...
Prestachamps Posted April 14, 2016 Share Posted April 14, 2016 Hi, - you have to add it to /themes/theme_name/js/modules/blockcart/ajax-cart.js, in a couple of places: inside function : overrideButtonsInThePage : function(){ - Here get the select's value and save it in a custom variable called MyExtraParameter ,and add as an extra parameter for function: ajaxCart.add(idProduct, idProductAttribute, false, this, minimalQuantity,MyExtraParameter); - then modify the add function, by adding your extra parameter like : add : function(idProduct, idCombination, addedFromProductPage, callerElement, quantity,MyExtraParameter, whishlist){ -Inside this function, you have to pass the parameter inside the ajax call : data: 'controller=cart&add=1&ajax=true&qty=' + ((quantity && quantity != null) ? quantity : '1') + '&id_product=' + idProduct + '&token=' + static_token + ( (parseInt(idCombination) && idCombination != null) ? '&ipa=' + parseInt(idCombination): '' + '&id_customization=' + ((typeof customizationId !== 'undefined') ? customizationId : 0))='&MyExtraParameter='parseInt(MyExtraParameter ), -you may have to add it to file /modules/blockcart/blockcart.php , add it in function: hookAjaxCall(..... (I am not 100% sure that you need to add it here, since all parameters are assigned to the json TPL) -lastly modify the file /themes/|YOURTHEME/modules/blockcart/blockcart-json.tpl , in order to be accessible in the ajax cart. Regards, Leo 1 Link to comment Share on other sites More sharing options...
shacker Posted April 26, 2016 Share Posted April 26, 2016 any results? Link to comment Share on other sites More sharing options...
Rhobur Posted May 9, 2016 Author Share Posted May 9, 2016 @leo: CC: shacker Sorry for taking so long in replying. I missed your post, somehow the forum notification didn't work. I circumvented this issue until now but it still bugs me so I will try what you said and get back with the results. Thank you for your help! Link to comment Share on other sites More sharing options...
Rhobur Posted July 9, 2016 Author Share Posted July 9, 2016 @Leo, Thank you for trying to help! Having a little spare time, just got back to my mod. I need to add a custom variable from the product list. So far I did: - added the variable MyVariable in the product-list's cart button data attribute; - declared it in the ajax-cart.js, added it to the ajax.add call; - declared MyVariable: {MyVariable} in the blockcart-json.tpl - since those variables are POST-ed to the cart controller I tried to retrieve MyVariable there in the displayAjax method but seems I can't find it. Any idea about how can I retrieve this variable? Kind Regards, Robert [sOLVED] Was looking at the wrong function. I needed the postProcess one. Thanks Leo for the pointers above. 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