Is it possible to add a product to the MarketPress basket that hasn't been pre-configured?

Hi,

I am re-designing a clients website that previously gave a customer a quote based on what they in-putted to the form and then gave them the option to purchase by adding it to a PayPal shopping cart.

Is it possible to add products to the MarketPress shopping cart / basket in this way?

A few more details to try and help you understand the situation.

My client has a foam conversion business and provide their customers with an online custom quote system.
The end user chooses their "rough" shape and enters their dimensions they require the foam to be cut to along with the type of foam.
The online form then processes the shape, type and size of foam and provides a price.
The customer can then currently add this to a PayPal shopping cart and choose their quantity.

To see it in action if that helps, my clients current site is http://www.acefoam.co.uk

They also have another website which contains fixed-price items and I am merging the two together. I already have MarketPress loaded with these items but the idea is to have just one website and one shopping cart to simplify things for the end-user.

Any help or advice would be greatly appreciated.

Thank you in advance :slight_smile:

Regards,
Chrystopher

  • aecnu

    Greetings Chrystopher,

    Thank you for the great question which is certainly appreciated.

    This is certainly not impossible considering that I have learned that when one is a competent coder with a vision and the will to get it done anything is possible - and I am not a coder.

    This is not really doable out of the box for Market Press and though I could have simply said no - but that would not be honestly trying to help.

    So what are the options?

    Trying to work them in as variations is one but not nearly as cool as putting in the dimensions of course and if it is custom by the end user it would require something to calculate the cost as well.

    So other then pre-configured variations would be custom coding which may or may not be an option you want to investigate but it is a sure fire way to possibly get this integrated with a competent coder.

    You could see if there's a developer available at wpmu jobs who could get onto it right this minute.

    One last option I just thought of - The online form then processes the shape, type and size of foam and provides a price - this can still be easily instituted and made to fit into the site by using the external link feature for the product to link to the form then all that needs to be done is figuring out how to get it into the cart.

    Thank you for being a WPMU Dev Community Member!

    Cheers, Joe

  • MELONPUP

    Hi Joe,

    Thank you for your reply, really appreciated :slight_smile:

    I have already got the code working on the primary website (www.acefoam.co.uk) to calculate the price, this then produces a buy now button which adds the custom item and price to a PayPal shopping cart. I'm currently building the new site at http://www.uat.acefoam.co.uk and about half way through the content and still working on a new branded theme, so it's just the TwentyEleven theme currently.

    So the solution that I'm looking for really is to insert the item in to the MarketPress shopping cart in the same way as PayPal. There won't be any need for MarketPress to do any of the calculations etc. Just to accept an Item Title and Price.

    Hope that makes sense?

    As it doesn't sound as if it is currently possible, could this be added to the Feature Request List?

    Regards,
    Chrystopher

  • aecnu

    Greetings Chrystopher,

    Thank you for kind reply and yes you have certainly shed some more light on what you have going on there and a way I may indeed be able to help you further.

    I was not really proposing on making Market Press do any lifting for this project, I was trying to come up with a way to integrate the form/system you have on this site http://www.acefoam.co.uk into Market Press on the new site and therefore my suggestion regarding using the external link function.

    Next is the tough one which is injecting the results from the form into the Market Press cart.

    This I will need help to give us clues on how to possibly get this part of the job done.

    Therefore I will see if I can get the lead developer in here with his invaluable insight into this plugin for his advice/advise for us.

    Though this may take a bit longer then a normal ticket, I will try to get him in here asap.

    Cheers, Joe

  • Aaron

    I don't see how this would be useful to add to core. You could certainly with some coding skills write your own plugin to generate a new product (wp post object) and add it to the cart. Or maybe better simply filter the price of a standard product based on entered attributes.

    That's about the extent we can help you here though, we don't provide custom coding services. But i'll stay subscribed to the thread in case you have any technical questions about integrating your code with MarketPress.

  • MELONPUP

    Hi Joe and Aaron,

    Thank you both for your responses, much appreciated.

    Personally, I believe having the MarketPress Shopping Cart function in a similar manner to PayPal's Shopping Cart would open up the possibilities and usage of MarketPress quite vastly, but I'll take your professional views over my personal thoughts any day :slight_smile:

    I have done what Joe suggested and posted the job here - https://premium.wpmudev.org/wpmu-jobs/project/paypal-style-marketpress-shopping-cart-to-accept-a-custom-title-price-rather-than-pre-configured-products/

    I will keep you updated on how we get on with this, but once again, many thanks for your help so far!

    Although I don't believe this to be resolved (it's been resolved twice), I will leave it as resolved from your support point of view (maybe having some other options like closed or not feasible would be better?).

    Regards,
    Chrystopher

  • MELONPUP

    Hi,

    Just thought I would add the section below which I wrote for a developer that has contacted me who is interested in working on this. Maybe it will shed a little more light in to what it is that I'm after. Rewording it is a bit like the saying "there are many ways to skin a cat" :slight_smile:

    In summary, I require a PayPal style Shopping Cart whereby I can push Items in to the MarketPress Shopping Cart (Items that have never and will never be added to MarketPress, just to the Shopping Cart).

    A working example (using PayPal) can be seen here - http://www.acefoam.co.uk - (follow the instant order link).

    I wish to replace the PayPal Shopping Cart with the MarketPress Shopping Cart so that it is more professional as it keeps the user on the clients website. Payment will still use PayPal but using the standard setup utilising the PayPal API.

    Many thanks in advance.

    Regards,
    Chrystopher

  • MELONPUP

    Hi,

    Another update on the progress with a summary of my conversations with various developers :slight_smile:

    Some of the questions asked were, would the custom cart created need to be displayed in the email sent to the customer regarding the products ordered and display the order on the front end to the customer and display the order in the back-end to admin users as well. Also can a customer add multiple custom products in to a single cart or not?

    Yes, to all, I would like the shopping cart to function exactly as it does to date. but with the added extra of being able to add the custom size foam and price to the basket. The customer would receive an email as per normal and they would be able to view previous orders online. They can also change the quantity of the item in the basket along with adding other custom items, if they so wish. They can also add normal products from MarketPress to the shopping cart as well.

    The developer mentioned that this change will require many changes to the MarketPress Plugin to handle this feature and that MarketPress Plugin can not be upgraded after this feature development, also that the shopping cart storage mechanism will aslo change. I was advised also whether this modification to the core MarketPress would be acceptable, which it wouldn't be really, I would still like to be able to update MarketPress for future features and security purposes.

    So, the solution that we are now investigating, based on what @Aaron mentioned, is to use "wp post object" and to create a New Product for every custom order and to assign them to a Custom Item Category.

    I know I mentioned in a previous update that these Items have never and will never be added to MarketPress, just to the Shopping Cart, but based on this not being part of core and to enable future proofing of the development, I have decided to have these added as products to MarketPress.

    Some of the Benefits are:
    1 - The Customer can re-order any previously ordered item
    2 - No modifications to MarketPress itself
    3 - Advertising as you can display the Last 5 Products ordered in a Sidebar Widget
    4 - Enables a product to be purchased by another customer that has the same requirements
    5 - Plus probably a few more :slight_smile:

    I will keep you updated on its progress :slight_smile:
    Hopefully this post will help someone else who requires a custom quote system (well, how to insert the items into MarketPress anyway)

    I just need to confirm the functionality with my Client before going ahead, always a good step :slight_smile:

    Regards,
    Chrystopher

  • aecnu

    Greetings Chrystopher,

    Just to clarify with you on the marking of the ticket as resolved.

    I personally mark tickets as resolved when I believe I have given a straight forward answer that should work and if it does not the member can simply check mark it as not resolved and post why they feel that way.

    Today I sent in a ticket for my server companies upline asking for more IP's that I need for a particular server - they wrote back that they cannot allocate me more for that server. They mark the ticket as resolved though indeed my need was not resolved, but form their perspective there is indeed nothing more they can do - therefore in reality it is resolved whether I like it or not.

    Concerning:

    I will leave it as resolved from your support point of view (maybe having some other options like closed or not feasible would be better?).

    You are indeed my hero concerning this topic and I could not agree more and I even hoped for a "custom coding" forum topic and from my understanding they have all been shot down in flames.

    We do have an option to close a ticket, but then it locks it down like this ticket has been closed:

    https://premium.wpmudev.org/forums/topic/gravity-forms-and-marketpress

    And nobody can add to it in any event.

    But still it is great input and thank you for that.

    Cheers, Joe

  • MELONPUP

    Hey Joe,

    Thank you for your reply and any chance of a few points for being your hero? :wink: haha

    After I posted my last reply, I did a search to see if anyone had previously done any work on adding new products to MarketPress from the Front-End. And guess what, I certainly did :slight_smile:

    This post and plugin Custom Products for MarketPress from Sean Johnson has helped me tremendously, so a huge thank you goes out to Sean from me :slight_smile:

    I have customised it slightly so that it also updates the price as well as the title. I have also added some code to update the product description after the product has been created as it was duplicating my quoting system code each time and I didn't want that. So the current method is to copy the current product and to create a new one. The code then runs through and makes the required changes.

    What I could do with help for from you great people is how to set the product category as this is not copied over, and actually, I would like to assign a different category anyway.

    Oh yeah, I have also had to comment out the line about setting the status to trash as the product wasn't showing up in the shopping cart.

    You can view it in action here but please note that it is mainly the functionality and process that I have been working on rather than design at this stage.

    Your views, thoughts, feedback and help with the above questions would be greatly appreciated :slight_smile:

    Many thanks in advance!

    Regards,
    Chrystopher

  • Sean Johnson

    Hey Chrystopher,

    I'm glad my little plugin was able to help you. I am making some improvements to it later this week. I'm mobile right now, as soon as I can I'll try to get you some more info and post an updated plugin. I'm just using some logic like below to assign the category:

    if( has_term( 'media-purchase', 'product_category', $old_id ) ) {
    	update_post_meta($new_id,'media',$_POST['the_post_id']);
    }

    I'm keep thinking about when the post is created on the fly to place it in a custom post type instead (but I haven't committed to this yet)... I also abandoned adding it to the trash (it was just a proof of concept for me) and now I place it in a specific category like shown above.

    Later this week I should have some enhancements that include cleanup of abandoned items and also a complete pay per post solution with gravity form integration :slight_smile:. E-mail me from my contact form: Contact Me

  • MELONPUP

    Hi,

    I keep meaning to post my findings, so I best do it before I forget :slight_smile:

    Just to let you know that there is a bug in the current version that once a product has been customised and added to the shopping cart, all additional items added also have their post copied and turned in to a new product.

    This is due to $_SESSION['custom_data'] being populated and therefore runs the function for every item added thereafter.

    The solution is to unset the variable at the end of the function as per below

    unset($_SESSION['custom_data']);
    		return $new_id;
    	}else{return $product_id;}
    }//end of function dls_create_product()
    ?>

    I still need to get around to implementing the category setting code :slight_smile:

    Regards,
    Chrystopher

  • MELONPUP

    Hi all,

    Whilst testing the website with a customised version of Sean's plugin and after unsetting $_SESSION['custom_data'] which was causing every additional product thereafter to be duplicated. I found that Firefox was still causing the duplication to happen. I use Chrome which is fine and I also had someone test AOL which was ok (except for it displaying the SimpleMarket Theme as if it was a phone) and IE9 works great.

    A bit more testing on Firefox shows that if you visit a product and add it to the cart, it gets duplicated when it shouldn't as it is a standard product. Whilst still on the same product you can add it to your cart again, this time it is successful, and none of this matters whether you choose a variable or not.

    If you then navigate the rest of the site and come back to the same product and add it to the cart, you get an exact repeat occurrence of the above, I.e. it duplicates the first addition but all future ones are ok (whilst still on the same page).

    Does any one know of why Firefox is operating differently to all other browsers or even better, a fix for it :slight_smile:

    You can try it out yourself if you want to using the various browsers by going to http://www.uat.acefoam.co.uk and clicking on the "Foam Sheets" category on the left hand side.

    Any help would be appreciated because at the moment, anyone ordering their first product via Firefox gets it free :slight_smile:

    Regards,
    Chrystopher

  • MELONPUP

    Hi,

    This is really bugging me now :-s

    If I add unset($_SESSION['custom_data']); to the template header, all duplication turns off.

    So I thought if I added it to the standard item that it would work, but nope, Firefox still calls the duplication code.

    PHP is server-side, so it's definitely something to do with the Session variable, and Firefox is messing up the Session :-s

    Any ideas or thoughts would be greatly appreciated.

    Regards,
    Chrystopher

  • MELONPUP

    Hi,

    Further investigations show that the Firefox browser is calling the product duplication function (which should only run where the Session Data has been set) when the Add to Cart button is clicked on a freshly loaded general product page, yet calling the custom code which is in a different product.

    It doesn't make sense as to why Server Side code would operate differently depending upon the Users Browser. I would kind of understand if it was session related, but I'm not so sure any more as I have found out that it is pulling in the code from a different product :-s

    This page has no Session Data and when accessed in Chrome, IE, AOL it adds the product to the basket correctly. When accessed in Firefox, it duplicates the Product based on this page, which makes no sense as this product is not related to the custom coding on the other page and the plugin (Sean's) does not specify the custom coding.

    Is this an issue with the MarketPress Hook Filter or possibly WordPress itself?

    Any help or guidance would be appreciated.

    Regards,
    Chrystopher

  • MELONPUP

    Hi,

    I believe the issue is resolved.

    I decided to manually recreate the fixed price item (which was being duplicated) and to delete the old one.

    The new product now adds successfully to the basket every time regardless of the browser being used.

    The only thing that has changed is that the Product ID is now greater than the Product ID which contains the custom coding, sets the Session Data variable, etc.

    I.e. The old product which was failing had ID of 6, the custom product has ID of 255 and the new product has ID of 662.

    Not sure whether the fault lies with WordPress, MarketPress or Sean's Code, but process of elimination has omitted my code, and looking at Sean's, there is nothing obvious that would indicate a Product ID Ordering.

    Maybe the Action Hook below could be looked at by a Developer on line 2502 of marketpress.php

    $product_id = apply_filters('mp_product_id_add_to_cart', intval($_POST['product_id']));

    That's all I can think of right now as being the issue.

    Regards,
    Chrystopher

  • MELONPUP

    Hi Sean,

    Sorry for the delayed reply and thank you for getting back to me. I have downloaded your latest version but it is the same as what I had already (0.0.2 rather than 0.0.3). Would it be possible to see what you have changed between these versions?

    Hi Joe,

    Thank you for having an interest in this. The code has been in place for quite a few months now and appears to be doing the job. I still need to sort out how to get the new product assigned to a category just to tidy it up a bit.

    All,

    I have posted a new thread here to do with the $_SESSION variables not being picked up and inserted in to the new product when using GridMarket. The code works ok with SimpleMarket and FrameMarket themes. So it is definitely related to the Theme rather than coding. But if you have any ideas, thoughts or suggestions, they would be greatly appreciated.

    You can see the code in action on the LIVE site (SimpleMarket) and the new TEST site (GridMarket).

    Both of these are standard Pages that contain a Form to collect the data. These are then posted to a Product page that contains the code to calculate the custom price. This code also sets the $_SESSION variables that are required for Sean's plugin. Both sites create a new Product, so the $_SESSION variables are being picked up by Sean's code, but the Test site is not seeing the actual contents of the variables.

    The only thing that is different, that I am aware of, is that GridMarket is a Child Theme and that it uses Echo to include other PHP scripts/functions.

    If anyone has any ideas on how to get $_SESSION variables working in this way, it would be very much appreciated.

    Thank you in advance :slight_smile:

    Regards,
    Chrystopher

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.