Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2010
    Posts
    3
    Plugin Contributions
    0

    Default Adding to cart from a swf file

    Hi,

    So I have been toying around with this for awhile. I have created a flash swf that will allow my customers to customize their product with a nice GUI. What I want to do is have a button at the end of the my flash product editor that will send it to the shopping cart. Right now I have the flash swf call a php file that creates a new product within the appropriate zencart databases and then it returns the products_id. This works 100% perfectly.

    Now I want to add this to the customer's cart. I have tried inserting the new product_id into the customers_basket DB, however, I ran into issues with the customer_ID number. It tends to want to default to 0 all the time. So i scratched that idea.

    I then began to analyze much of the zencart code within various. Based on my research of the files and researching many threads, I have come to the conclusion that when a call is made to the following:

    Code:
    http://www.domain.com/index.php?main_page=product_info&cPath=###&products_id=###&action=add_product
    (### being the categories ID and the product ID respectively)

    the product is added to the cart. I have also come to the understanding that the variables cart_quantity, product_id, and any attributes involved with the product are sent as parameters using POST.

    What I have tried doing is sending the parameters to that URL within AS3 (i can post this code if necessary). This did not work and the page just said "transferring data from ....." and did nothing.

    My next step was to try it from my php function that I call from the flash that has been working to submit new products to the zencart DBs.

    Code:
    $postdata = http_build_query(array('cart_quantity' => '1','products_id' => '33'));
    
    	$opts = array('http' => array(
            'method'  => 'POST',
            'header'  => 'Content-type: application/x-www-form-urlencoded',
            'content' => $postdata
    		));
    
    	$context  = stream_context_create($opts);
    
    	$result = file_get_contents('http://www.domain.com/index.php?main_page=product_info&cPath=###&products_id=###&action=add_product', false, $context);
    What this is doing is returning the code of the shopping_cart page


    Any ideas?

  2. #2
    Join Date
    Apr 2010
    Posts
    3
    Plugin Contributions
    0

    Default Re: Adding to cart from a swf file

    Disregard! I went back to my original method with using the POST methods within flash. I got it to work. I had to edit my Crossdomain.xml file!

 

 

Similar Threads

  1. IE/Chrome problems with adding animated gif or swf file
    By Congerman in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 29 Oct 2011, 10:57 PM
  2. SWF Flash File in Banner Manager
    By Oriontool in forum Templates, Stylesheets, Page Layout
    Replies: 6
    Last Post: 5 Oct 2009, 04:14 PM
  3. replace item image with a swf file
    By Fireburst in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 12 Sep 2008, 10:14 PM

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