Dave Coder Posted March 23, 2018 Share Posted March 23, 2018 Love Cubecart! I am only using CubeCart as a catalog, but I'm trying to add a simple Form CGI POST script for a 'Buy Now' button in the Product Description. This will send a very small amount of product information to my bolt-on commerce cart (Americommerce). This works great in all of my websites (including Joomla Virtuemart), but within CubeCart it does nothing when I click on the 'Buy Now' button. I imagine this may have to do with the 'security token' sanitizer. Is there anyway to simply make a call to my bolt-on commerce cart using CGI script? It's always been so easy within HTML and other PHP -based websites... works like a charm on all form data. Any help would be appreciated. PS.The reason I use the bolt-on cart to manage my commerce is that I have many websites being hosted across many domains. I don't want to setup a new commerce system for each website. I use a single bolt-on commerce system across all websites to manage shipping, customer communications, etc. from Americommerce without logging into 20 different instances of a shopping cart to do the same thing. Quote Link to comment Share on other sites More sharing options...
bsmither Posted March 23, 2018 Share Posted March 23, 2018 Welcome Dave Coder! Glad to see you made it to the forums. CubeCart has a "catalogue" mode. As such, CubeCart presents no method to add items to a shopping cart, to show a shopping cart, or to checkout the shopping cart from the store. However, there is still a form element that contains much of the item's displayed matter: image, price, description (but not Customer Reviews nor anything after). If you have this mode enabled, then I conclude you have incorporated a separate form element in the product's Description. Only when CubeCart processes a POST payload is the security token examined and changed (that may change in CubeCart 6.2). CubeCart also attaches javascript event viewers to the form element courtesy of the jquery Validate plugin. Regardless, nested form elements are not permitted. We may need to work out how to remove CubeCart's form element to allow yours to function. Quote Link to comment Share on other sites More sharing options...
Dave Coder Posted March 23, 2018 Author Share Posted March 23, 2018 Thanks for the feedback, b. Yes, I only use catalog mode so CubeCart presents no method for adding to it's own shopping cart. I simply paste html code into the product description area. It then add to my bolt-on shopping cart (Americommerce). See my example on this page: http://labdirect.net/index.php/carbamide-peroxide-teeth-whitening-gels/carbamide-peroxide-5ml-syringe-16-8-9-detail. The same code in CubeCart is rendered non-functional so something's going on there. Any ideas, let me know. Lovin' CubeCart! Quote Link to comment Share on other sites More sharing options...
bsmither Posted March 23, 2018 Share Posted March 23, 2018 I am not able to assist as I believe the link provided is not a CubeCart page. If you can provide a web address of a CubeCart store exhibiting the problem, we may have some advice. Quote Link to comment Share on other sites More sharing options...
Dave Coder Posted March 23, 2018 Author Share Posted March 23, 2018 Of course. Sorry about that. Take a look at the CubeCart page at: http://labdirect.net/cube/bulk-tube-44-carbamide-peroxide-teeth-whitening-gel.html Quote Link to comment Share on other sites More sharing options...
bsmither Posted March 23, 2018 Share Posted March 23, 2018 Ok, I see that you have simply added an <input> tag to the description, and are relying on CubeCart to process the POST. If you do not care how CubeCart manages your inventory, then you can rewrite the skin code to not POST to CubeCart (which is as an AJAX call - likely why you see no effect as there is nothing for the AJAX result function to change). Instead, set the action attribute to your CGI script, and then have that script send a 302 redirect back to the browser to refetch the CubeCart page. If you run your own server, you can certainly have your PHP allow for executing scripts that do not belong to CubeCart. We can use any of several hooks to call that script. Quote Link to comment Share on other sites More sharing options...
Dave Coder Posted March 23, 2018 Author Share Posted March 23, 2018 Thanks for the help. I'll look into several of the solutions you mentioned and let you know what I come up with. Quote Link to comment Share on other sites More sharing options...
Dave Coder Posted March 28, 2018 Author Share Posted March 28, 2018 Thanks B, I don' need inventory control. Just a simple input directly to my bolt-on shopping cart without AJAX handling it would be great. I can't find where to rewrite the skin code to not POST to Cubecart. Any help would be greatly appreciated. Quote Link to comment Share on other sites More sharing options...
Dave Coder Posted March 29, 2018 Author Share Posted March 29, 2018 Anyone? Quote Link to comment Share on other sites More sharing options...
bsmither Posted March 29, 2018 Share Posted March 29, 2018 Working it out in my head. Quote Link to comment Share on other sites More sharing options...
bsmither Posted March 30, 2018 Share Posted March 30, 2018 Let's look at the Foundation skin template main.php. Line 14 can be changed: From: <form action="{$VAL_SELF}" method="post" class="add_to_basket"> To: <form action="http://www.cartserver.com/sc/cart.cgi" method="post"> Then, in the product's description, remove the <form> and </form> tags. I don't see an <input> that will send the {$PRODUCT.product_id}. Then, have an <input> that sends {$VAL_SELF} so that the script can send the visitor back to this page. Quote Link to comment Share on other sites More sharing options...
Dave Coder Posted March 30, 2018 Author Share Posted March 30, 2018 Thanks B, Looked at code in main.php at skins/foundation/templates/main.php. I guess I'm showing a different file than you describe. No 'form' code at all there to modify. Sorry for the hassle and thanks so much for the help. Seems so simple, but apparently not. If you ever run across a simple way to send form data directly in from cubecart product description, let me know. Thanks again. Quote Link to comment Share on other sites More sharing options...
bsmither Posted March 30, 2018 Share Posted March 30, 2018 My bad. Must have been a long night. Let's look in content.product.php. Quote Link to comment Share on other sites More sharing options...
Dave Coder Posted March 31, 2018 Author Share Posted March 31, 2018 Haha... "No rest for the weary". Thanks. Quote Link to comment Share on other sites More sharing options...
Dave Coder Posted April 3, 2018 Author Share Posted April 3, 2018 Thanks B! I was able to get the form working by completely removing line 14 (<form>) in content.product.php and replacing it with my form and input data. The fix is a bit 'squirrelly', but it works. The RTF editor for product description still adds a token (that is now unused) after each edit (like a blockchain database... haha). I'll continue playing with things and update this topic as I continue tweaking. Thanks for pointing me in the right direction. CubeCart Rocks and so do you! Quote Link to comment Share on other sites More sharing options...
Dave Coder Posted April 4, 2018 Author Share Posted April 4, 2018 Quickie. May need to start a new post. I will be disabling the 'Login / Register' links across the site. Is there an easy way to do this? Quote Link to comment Share on other sites More sharing options...
bsmither Posted April 4, 2018 Share Posted April 4, 2018 The login/register HTML in the displayed page is a common box - shown on all pages*. So, in main.php, you can make this change: From: {include file='templates/box.session.php'} To: {* include file='templates/box.session.php' *} This keeps the code but the syntax is a comment. * If a visitor manages to get to the Checkout page, there is a form that can be filled out which will register a customer. Also, even with no links visible, one can manually enter the web address: www.store.com/register.html. The 100% positive measure to stop visitors from registering will require some code snippets. Quote Link to comment Share on other sites More sharing options...
Dave Coder Posted April 4, 2018 Author Share Posted April 4, 2018 Thanks B. Fast and 'right on the money' as usual. In file, box.sessions.php, I hardlinked the Login / Registration links directly to my bolt-on shopping cart. Hooray! Now to start populating with products and go live (in a few days). Thanks for the help. You da man! Quote Link to comment Share on other sites More sharing options...
Dave Coder Posted April 5, 2018 Author Share Posted April 5, 2018 Is there any way to disable the responsive main menu? It's not necessary for my store (no login). I've hidden all links to the login on desktop site, but for phones the responsive menu kicks in. Thanks! Quote Link to comment Share on other sites More sharing options...
bsmither Posted April 5, 2018 Share Posted April 5, 2018 The black bar across the top? Quote Link to comment Share on other sites More sharing options...
Dave Coder Posted April 6, 2018 Author Share Posted April 6, 2018 The side menu on mobile that slides out from the left. Menu items are 'Your Account > Login / Register' and 'Change Currency'. I just need to disable that menu (or modify the links). Quote Link to comment Share on other sites More sharing options...
bsmither Posted April 6, 2018 Share Posted April 6, 2018 That is in box.off_canvas.left.php. Quote Link to comment Share on other sites More sharing options...
Dave Coder Posted April 10, 2018 Author Share Posted April 10, 2018 Thank you, B! That's just what I needed (as usual). 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.