Publisher does not support the Fluid field type. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: Action ID not set for CartThrob Add to Cart action

Status Resolved
Add-on / Version Custom System Messages 2.5
Severity
EE Version 2.8.1

Felix Brooks

Apr 14, 2015

I bought this plugin because I wanted to produce custom error pages when adding to cart with cartthrob, i.e. when a user tries to add a quantity greater than the available inventory. However, when I submit a form to create this error my custom action template doesn’t load, instead my default submission template is shown. I then tried to check the action id in the default submission template to output my custom error that way. However the action variable doesn’t seem to have been set. Both {action} and {csm:action} output nothing.

I read in another post that I may have to use the none on error action but I have tried both actions:

(17) Add To Cart Action
(17) Add To Cart Action (On Error)

Further to this if I let my form expire and then refresh it does go to my custom template! Also {action} and {csm:action} both correctly output 17.  However, this isn’t much help as I need my custom template to work when the form is originally submitted.

#1

BoldMinded (Brian)

I don’t have Cartthrob installed, so I can’t debug or replicate this. There is no telling what Cartthrob is doing behind the scenes. If it isn’t using the native error handling, then CSM won’t pick up on it. Can you email me the Cartthrob zip file so I can take a look at the code? I won’t setup anything to replicate this locally, that would take me forever. If I can’t tell anything from looking at the code then I’d need you to provide FTP access for me to debug this.

#2

BoldMinded (Brian)

support at boldminded dot com

#3

Felix Brooks

Have sent this as requested. As far as I know it uses native error handling - you get the same ugly errors you do with standard expression engine.

#4

BoldMinded (Brian)

Find their Form_builder.php class and comment out these lines of code. https://www.dropbox.com/s/hxbgp07wfomi2wl/Screenshot 2015-04-14 06.34.53.png?dl=0

The comments above those lines of code look like they are not happy with something in EE, but I don’t know what it is.

I don’t see any instance of show_message() in their codebase, which is the EE function they need to call to render that template. show_error is an exception handler which does not run through EE’s output class, thus not through show_message(). So from what I can tell they are using their own error handling. You can try using their inline error messages instead.

#5

Felix Brooks

Ok, so commenting out those lines does seem to fix the issue and I am getting through to my custom template now and the action variable is set and accessible so I should now be able to achieve what I wanted to.

Strangely the link variable is now broken though!

{link} now generates this:

<a href="http://removed">history.go(-1);”]« Back</a>

I can get around this using my own links and the {referrer} variable though I think.

#6

BoldMinded (Brian)

The back link is default EE behavior, it isn’t broken. I don’t know the reasoning behind not using the native error page. It obviously throws a wrench in other addons and messes with EEs native behavior. I’ll send this to cartthrob for them to sort out.

#7

Felix Brooks

I made a mistake, it isn’t {link} that generates that broken back link, it is appended to the end of {content} for some reason.

CartThrob mention in that section you asked me to comment out and say it is an ExpressionEngine bug that causes it.

I am just using cutting the end of the string off {content} now as a work around. Bit messy but I have managed to achieve what I wanted to do.

Login to reply