Hint: To start off, set a custom site name, email address, street address, contact person, etc. Make any adjustments required with the Theme. Step One: Install the Ubercart Modules. Country: Handles country settings and management for your Ubercart site.
|Published (Last):||3 April 2004|
|PDF File Size:||11.55 Mb|
|ePub File Size:||14.83 Mb|
|Price:||Free* [*Free Regsitration Required]|
I've recently created a new module for Drupal's Ubercart e-commerce solution that required me to add a new line item to the checkout process. So I have decided to post the process here for three reasons:. Disclaimer: I make no claims that this tutorial is exhaustive. As of the time of writing, it is the process that I used in order to implement new line items for the purpose I needed. There may be a few parts that I didn't need for my own purposes that can be implemented in line items.
Please feel free to add them in the comments. Please include where in the process the step should occur, and as much detail as you can. The first thing we need to do is create a new pane on the checkout page where we can select our new line item. This step may not be required if your line item is determined somewhere before the checkout process. However, if your line item is determined by clicking a checkbox or selecting from a list, this step will be required.
In my module, I was adding a gift wrapping option to the checkout process. As such, I needed to add a checkbox to the checkout page, where the user could choose to have the order gift wrapped wrapping came with a 3 pound surcharge.
The key to this hook is the callback function that is defined. Here is an example of the hook definition:. Next we will look at the callback function for the hook defined above. First, the callback function definition:. Now let's look at an example of how we will handle the above form fields upon checkout form submission. So now we have finished defining the new pane in the checkout process.
Let's look at the script:. While we have created the line item, and caused it to be able to be added to the display on the checkout process by checking the checkbox, this value will not yet carry over to the order review page. We will take care of this step in the process here.
In this section, if the line item needs to be added, we will use the function :. However this tutorial does not save any custom information to the database, so I will not be adding that step.
This tutorial doesn't actually use this step. In my real module this was the text that would be applied to the message card that when the user gets gift wrapping.
This is a little out of the scope of my tutorial though, so I will leave this out for now unless someone specifically requests it. Hopefully this will save you some of the many troubles and headaches I had trying to figure out how this all worked. Good luck, and please feel free to leave any comments below! Thanks, this might be exactly what I'm looking for!
I'm going to use these steps for a project of mine. I'll let you know if I have any success implementing this. I succeeded implementing this tutorial in my project. Thanks a lot again for this very well documented tut!!! Regardless, I've got this working at www. Thank you! Have you thought about contributing this to some Drupal. This is even better than some of what they have there at least specifically with respect to Ubercart and the pane and line item hooks.
I'm glad it helped. I agree with you that it was hard to find any kind of explanation on ubercart. Fortunately, I've got a pretty solid handle on how Drupal works as a whole, so it was just a matter of figuring out what hooks were being called, when they were being called, and what the values being passed were.
So I'm glad to hear that this helped! I considered putting this on ubercart. I've got a few modules up on drupal. There is a responsibility that goes along with being responsible for code on other people's sites. Same with putting this tutorial up on drupal. I basically see how it works now, but I'm still relatively new to it, as I'm just finishing my first site that incorporates Ubercart into it.
So for now, I'll just keep my tutorial here. I'll come back to it at some point when I have a little more experience with it, and check that it all looks valid. I understand and agree with your answer, thanks for sharing. However, i still have a bunch of questions. Question 1: If i use. I'm sure this is a result of a bit of ignorance on my part- with respect to standard variable passing between functions.
Question 3: The module i created specifically created 2 new line items within the same line item hook function that are then displayed within the same pane. I ideally wanted to add these line items to the already-existing Delivery Information Pane at the bottom Thanks again for your contribution - it has been a pleasure learning and beginning to grasp Drupal hooks!
Im impressed. Youre truly well informed and very intelligent. You wrote something that people could understand and made the subject intriguing for everyone. Im saving this for future use. Hey Jay, thanks for the tutorial. I am giving two types of discounts. I'm sorry, I'm not sure exactly what that would be, and unfortunately that's the kind of problem I would probably need direct access to the site plus an hour or two to properly diagnose.
Maybe it's something set on your conditional actions for taxes? Im always happy to see anything that clears up some of the confusing docs from ubercart.
It seems like a good place to do one-time processing on an order that just went through checkout, but some googling reveals that its real purpose is to do some validating during checkout I know, validating during a submit op Learning that fact almost ruined my weekend Well Well Well. Awesome tutorial. Thanks a lot Man, helped me a lot. I need to add a line item but I don't need a new pane, because my line item price is based on Delivary Address. I actually create the Line Item and it is adding an initial value that is fine, but when the delivery address is modified, it is not updating the Line Item price.
Really appreciate that you've shared this tutorial with the community. It's a excellent resouce. Great work. Would it be possible for you to go a little further and include the steps necessary to add custom data to the order status page, as you've indicated having done in your module with the text applied to the message card by users getting gift wrapping.
It looks like some of the API changes in ubercart 2. A pre-save hook was added as well. When I use uc coupons or my custom discount, everything works. When I combine them, something break horribly! I hope no one else is experiencing any issues from the latest changes. If anyone else is getting weird behavior, try that. Hey thanks for a good article. You are right: you saved me a bunch of time :- Didn't use exactly as prescribed, I still haven't bothered with Drupal JS too much because jQuery is so easy but basically, yes.
Part of a much bigger function for displaying and passing in a line item for delivery from multiple vendors with different delivery rates for different zip codes. I display a table of fees in real time, and process the fee on form submit, just like you did.
Ubercart: Creating Line Items Tutorial (Drupal 6)
How to Install & Configure Ubecart with Drupal