Page 1 of 2 12 LastLast
Results 1 to 10 of 15
  1. #1
    Join Date
    Apr 2008
    Location
    Athlone, Ireland
    Posts
    176
    Plugin Contributions
    5

    Default Adding products from website form (not from admin)

    Hi,

    I have zencart installed in a subdirectory (public_html/trades/) of a domain, I also have a website on public_html/.

    I want to use the website to collect data using a form which will post the data to zencart as a product.

    I have been struggling with it for a while and am having a problem with a few things and hoped that someone maybe able to help me.

    Whats happening is when the form is processed it runs a mysql statement:

    Code:
    $query = "INSERT INTO zen_products (products_model, products_quantity, products_image, products_date_added, products_status) VALUES ('$model','3','product.jpg', NOW(), '1')";
    $query = "INSERT INTO zen_categories_description (categories_name) VALUES('$county')";
    What im having dificulty with is the categories bit. It will put put the data into the categories_name, but it will duplicate the category name and it doesnt show in admin > categories/products either.

    I am presuming that I need to post the categories_id instead of the categories_name, but I have no idea how to set that up on my form processor.

    I have tried using an array but thats not working either:

    Example:
    Code:
    $county[Dublin]='1';
    $county[Roscommon]='2';
    $county[Galway]='3';
    $county[Westmeath]='4';
    I have no idea where to go from here. I will keep trying, but if anyone has a solution or can point me in the right direction, i will be their best friend :)

    dropbop

  2. #2
    Join Date
    Apr 2008
    Location
    Athlone, Ireland
    Posts
    176
    Plugin Contributions
    5

    Default Re: Adding products from website form (not from admin)

    OK, so i have managed to get this kinda working to an extent where in admin you can see that x category has x number of products, but when you open the category in admin, it doesn't show the products.

    I know im getting closer, but I think I need a little help from here. Is there another entry to the database needed to make the products show on the website?

    Here is where i am at so far:

    Code:
    <?php
    $dbhost = "localhost";
    $dbname = "xxxxxxx";
    $dbuser = "xxxxxxxx";
    $dbpass = "xxxxxxxx";
    
    mysql_connect ($dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
    mysql_select_db($dbname) or die(mysql_error());
    
    $name=$_POST['name'];
    $email=$_POST['email'];
    $telephone=$_POST['telephone'];
    $address=$_POST['address'];
    $size=$_POST['size'];
    $material=$_POST['material'];
    $handrail=$_POST['handrail'];
    $description=$_POST['description'];
    $timeframe=$_POST['timeframe'];
    $budget=$_POST['budget'];
    $termsagree=$_POST['termsagree'];
    $date= date("F j, Y");
    $model = time();
    $processed=$POST['processed'];
    $county=$POST['Dublin']='1';
    $county=$POST['Roscommon']='2';
    $county=$POST['Galway']='3';
    $county=$POST['Westmeath']='4';
    
    $query = "INSERT INTO zen_products (products_id, products_model, products_quantity, products_image, products_date_added, products_status, master_categories_id, products_price, manufacturers_id) VALUES ('$model', '$model','3','product.jpg', NOW(), '1','1', '4', '0')";
    //$query = "INSERT INTO zen_products_description (products_id, language_id, products_name, products_description) VALUES ('$model', '1', 'Decking Quote Request', '$description')";
    //$query = "INSERT INTO zen_products_to_categories (categories_id) VALUES ('$county')";
    mysql_query($query) or die(mysql_error());
    mysql_close();
    ?>
    <?php
    
    mysql_connect ($dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
    mysql_select_db($dbname) or die(mysql_error());
    
    $query = "INSERT INTO zen_products_to_categories (products_id, categories_id) VALUES ('$model', '$county')";
    //$query = "INSERT INTO zen_products_description (products_id, language_id, products_name, products_description) VALUES ('$model', '1', 'Decking Quote Request', '$description')";
    //$query = "INSERT INTO zen_products_to_categories (categories_id) VALUES ('$county')";
    mysql_query($query) or die(mysql_error());
    mysql_close();
    ?>
    I really could use a few pointers here

  3. #3
    Join Date
    Apr 2008
    Location
    Athlone, Ireland
    Posts
    176
    Plugin Contributions
    5

    Default Re: Adding products from website form (not from admin)

    All fixed now!

    The problem was, I had a sql statement that was INSERTing to the categories_description table, but took it out earlier while troubleshooting, but put it back in and it seems to work fine now.

    So now I can use a public php/html form to add products to my zen cart...

    If I get some time later I might make a post on how I did it. Not sure if anyone is even interested in this way of adding products, but you never know.

    Actually, is you are interested, hit the reply button to me to show your interest and I will then create a test site showing what happens and will post a how-to on this forum too.

  4. #4
    Join Date
    May 2010
    Posts
    125
    Plugin Contributions
    0

    Default Re: Adding products from website form (not from admin)

    That would be an amazing option I would love to use it, Please please post.

  5. #5
    Join Date
    Apr 2008
    Location
    Athlone, Ireland
    Posts
    176
    Plugin Contributions
    5

    Default Re: Adding products from website form (not from admin)

    Glad your interested in it shanesoine :)

    I will do up a post in a few days for it.

    Basically, what I was trying to achieve is to be able to let people add their own products to my cart using a web form which inserts the results to my zencart database.
    I am using it for a service where people post their details about a project they want to get a quote for, the details are posted on the zen cart site where the details of the job are shown to service providers who are interested in quoting for the job. When a service provider purchases the details to quote (the product) the full details, including contact details will be available to them so they can contact the potienial client and provide them with a quote. Each "product" has a quantity or 3 so only 3 service providers can purchase the full details.

    Im still workign on it, but you can have a test of it here before I add the captcha:
    This is the main site where people add details of the work they want done: http://timberdecks.ie
    Then go here http://www.timberdecks.ie/trades/ this is the zen cart site where service providers will purchase quote requests.

    Like I said its still not complete, but should let you have a glimps of it working.

    Hopefully I will find some time to get back here in a few days and post some sort of how-to.

    Anyway, I better get back to it or I will never get anywaywhere LOL

    Oh and Happy Mothers Day to all the Mothers on here!! :) (Dont know about the rest of the world, but its mothers day here in Ireland)

  6. #6
    Join Date
    Jun 2008
    Posts
    70
    Plugin Contributions
    0

    Default Re: Adding products from website form (not from admin)

    I'm interested in that. Can you show how it's done?


    Thanks

    Kevin

  7. #7
    Join Date
    Apr 2008
    Location
    Athlone, Ireland
    Posts
    176
    Plugin Contributions
    5

    Default Re: Adding products from website form (not from admin)

    Hi Kevin,

    I will be psoting a how-to here in a few days.

    The code will be from the way I have it set up, so it will need to be altered slightly for different set-ups. For example, I dont use the Auto increasment to set the ProductID in the database, My form sends a unique priductid every time its submitted - my productID is also the same as my model field. I wont ever have to add a product from the admin (it is all works as it should) so i dont need to use the auto increasement on the productID. But im sure with a little tweeking, I could set the admin side to post the productid as the form on my website does.

    Anyway, ill be back soon with the how-to :)

  8. #8
    Join Date
    Jun 2008
    Posts
    70
    Plugin Contributions
    0

    Default Re: Adding products from website form (not from admin)

    Quote Originally Posted by dropbop View Post
    Hi Kevin,

    I will be psoting a how-to here in a few days.

    The code will be from the way I have it set up, so it will need to be altered slightly for different set-ups. For example, I dont use the Auto increasment to set the ProductID in the database, My form sends a unique priductid every time its submitted - my productID is also the same as my model field. I wont ever have to add a product from the admin (it is all works as it should) so i dont need to use the auto increasement on the productID. But im sure with a little tweeking, I could set the admin side to post the productid as the form on my website does.

    Anyway, ill be back soon with the how-to :)
    Hey dropbop, I just thought about something. If you have it set to send a "unique or random" id along, then depending on how you have the unique field setup, you'll need to be certain that it wouldn't generate a product id that already exists.

    Now, I can see that if you start after the "highest number" id count and set it for after that point, but it has to somehow do a validation back to the id field.

    I can see this being very useful as it has been constructed so far by you. If I can help out in any way, just me know and I'll see what I can do. But I definitely want to check it out once you're completed your starting point.

    Kevin

  9. #9
    Join Date
    May 2010
    Posts
    125
    Plugin Contributions
    0

    Default Re: Adding products from website form (not from admin)

    thats great news - sure tweeking will challenge me I want clients to be able to use their used books on our site and track their credits.Looked at the affiliates program but could not see a way to fit it to our needs looking forward to your post. OO and thanks for the Mothers Day greeting

    Shane

  10. #10
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Adding products from website form (not from admin)

    I wonder if this would be vulnerable to SQL injection or other hacks... If you used some of the built-in Zen Cart db functions, you could probably be sure of safety.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v150 Adding a Customer from the Admin Area (do not need email)
    By swelter83 in forum Managing Customers and Orders
    Replies: 3
    Last Post: 13 Jan 2012, 01:37 PM
  2. Adding product to shopping cart from another website
    By badarac in forum General Questions
    Replies: 2
    Last Post: 19 Aug 2010, 04:11 PM
  3. Replies: 3
    Last Post: 15 Aug 2009, 03:38 AM
  4. input products from a form
    By jayty97 in forum General Questions
    Replies: 3
    Last Post: 19 Mar 2008, 04:22 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR