Quantcast
Channel: WHMCS Community Forums
Viewing all articles
Browse latest Browse all 13458

So I'm developing an addon for selling physical products.

$
0
0
Well I needed this functionality it's very basic just tax subtotal and basic shipping leveraging fedex and ups remote api. Also added further descriptions to configurable options that show on the product page. Got my shipping pricing showing on the configure page but when going to the cart it doesn't show up. Which I kinda expected anyway so since my shipping calculator populates a select I just gave it a name and figured I'd go ahead and have a second hook for pulling the post from that control into a smarty variable from there I would write a little javascript like I did on the previous page and update the total price. Then on checkout itself I may have to do a little behind the scenes magic to get it posting the new price rather than the one in the db. Anyway it was when I was trying to grab the post variable that I kinda got a little miffed. Mostly because when moving from one cart page to another it posts originally as expected then refreshes twice. Ergo the post variable is gone before I can capture it. Needless to say that's annoying as all get out. Also to get my javascript to play nice and be able to build a proper json array for the descriptions I ripped out the entirety of the {if $configurableoptions}{/endif} and re-wrote the entire thing in my hook as pure php that returns a string to a smarty variable with the output. That works great and keeps me from putting my entire context array into smarty when I don't need it on every page. Aside from that theirs a bit more data replication in there than I realized so half the time I don't need many of the variables. Although I did use it extensively in the admin portion of my code.

Either way that leaves me with the issue of getting my posted data into smarty somehow when the hook is hit the data no longer exists... which kinda makes me a sad panda. I suppose I could just slap it into the client area global hook and see if I can catch it there in some kind of.

Code:

if(!empty($_POST['shipping'])){
$smarty->assign('shipping',$_POST['shipping']);
}

That way if the page gets re-posted and the variable is empty it will have already been passed to smarty. As for the normal isset call that you would usually do there I noticed WHMCS doesn't propagate object errors to Apache error log anyway. So I'm omitting it perhaps theirs a setting to do that but I haven't found it. In any case I'll attempt to move that to the global hook but beyond this I don't know what to do to grab the variable before the page gets refreshed and blamo it's gone.

Viewing all articles
Browse latest Browse all 13458

Trending Articles