Custom Products for MarketPress

Hi All!

I wanted to share with the community a little plugin I designed to allow a product to be 'customized', then added to the cart, then checked-out, and then have those customizations (or personalized products) to be noted on the actual order for fulfillment purposes.

This is by no means, a complete solution there are some pieces left to develop (documented below) that I may tackle in the near future, OR, the Marketpress developers are more than welcome to taylor and "professionalize" for their next releases.

BACKGROUD: (Specifically, why this was developed):
I needed a way to pass information through the marketpress shopping cart and end up on my customers' orders. I only had a small amount of actual products, but each one of them needed to be designated to person. For instance, my customer was buying flowers for "Susan". I needed my customer to specify this person. Now, in my case, i did this progammically and "Susan" was being stored in a $variable on one of my pages- (aka. susan's page). On Susan's page, I had a section that said "products available for Susan" - in this section the user clicked the add-to-cart button next to the flowers they wanted to buy and the checkout process would begin. By design, Marketpress does not currently have the ability to pass any kind of customer chosen/generated input through the shopping cart and then eventually onto the order. You can only add this kind of custom data at the end of the checkout process, which was not applicable, and a-bit clunky for my needs. So... I wrote this plugin that actually clones an existing marketpress product on-the-fly (when the add-to-cart button is clicked) and adds the customized information to the new product. You are welcome to adapt for your specific needs:

MarketPress Custom Products Plugin

IMPORTANT NOTES TO UNDERSTAND:
This plugin works by cloning a product just before the cart is updated, using this newly cloned product you can add custom information to an item. NO CHANGES to the MarketPress plugin need to be made! I use a filter hook on line 2502 to return the new cloned product ID in place of the original.

USAGE / INSTALLATION:
1) place the marketpress_custom_products.php file into a folder and upload it to your plugin's folder within wordpress, activate the plugin from the wordpress admin.
2) modify your wordpress theme/post/page to populate the session variable "$_SESSION['custom_data']" with AJAX prior to the add-to-cart button being clicked.

NOTES:
1) A product will only be cloned if $_SESSION['custom_data'] exists in the current session. (This could be adapted to accept a user input for something like a person's name that will be embroidered onto an hat ... or any other type of custamizable product, but you will most likely need to use AJAX)
2) The cloned product is immediately placed into the trash bin so that it cannot be seen in the front-end (and so there is still a record created).

TODO / KNOWN ISSUES:
1) Create a function to handle inventory adjustments of the cloned products - as of now, inventory is not adjusted at all.
2) Create new a post_status specifically for custom products instead of using the 'trash', OR, marketpress developers can create a custom post type just for custom products for future releases, or they can dream up a better solution all together! :slight_smile:

We would love to hear your specific needs and feedback! If you need help implementing, we will try our best to help.

PS: This tread talks much about MarketPress handling of Customized products prior to checkout.
AND this thread was where this little plugin all started! BIG thanks @PaulM and @Aaron and the rest of the WPMU Dev team!