Pages

Tuesday 14 February 2012

WP e-Commerce digital product Download link on google checkout

When you are working with WP e-Commerce plugin for word press linked with Google Checkout for payment .and your shop is for  Digital Product and you feel you need more from this plugin then you are in right place . I have many issues  while configuring this plugin for one of my shop
1. Unable to display download link for digital products  after checkout .
2. No links to download digital product after Google checkout .
3  WP e-Commerce  add multiple  entries to  for single transaction
 4.Google checkout send Pending for shipping mail to user which in confusing .

Solution:
the problem is plugin is not sending google information about the product . it just sends its pricing details.  to fix this go ahead and modify  phugins PHP files

Step 1 Go to Location "..\wp-e-commerce\wpsc-merchants"
Step2 . Open    GoogleCheckout-XML.php
Step 3. Go to Line number  182  ( just above   $cart->AddItem($cart_item); )
Step 4.Add below code to it just before  line $cart->AddItem($cart_item);
  
//Extra code  send media download url to google checkout  
   $siteurl = get_option('siteurl');
   $previous_download_ids = array(0);
   $product_id = wpsc_cart_item_product_id();
   $link = "";
   //$product_data = $wpdb->get_row("SELECT * FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `id`='{$product_id}' LIMIT 1", ARRAY_A) ;
   $wpdb->query("UPDATE `".WPSC_TABLE_DOWNLOAD_STATUS."` SET `active`='1' WHERE `product_id` = '$product_id' AND `purchid` = '{$purchase_log[0]['id']}'");
   
   $download_data = $wpdb->get_results("SELECT * FROM `".WPSC_TABLE_DOWNLOAD_STATUS."`
       WHERE `".WPSC_TABLE_DOWNLOAD_STATUS."`.`active`='1'
       AND `".WPSC_TABLE_DOWNLOAD_STATUS."`.`purchid`='".$purchase_log[0]['id']."'
       AND `".WPSC_TABLE_DOWNLOAD_STATUS."`.`product_id` ='".$product_id."'
       AND `".WPSC_TABLE_DOWNLOAD_STATUS."`.`id` NOT IN ('".implode("','",$previous_download_ids)."')",ARRAY_A);
     
     $link=array();
     if(sizeof($download_data) != 0) {
      foreach($download_data as $single_download){
       if($single_download['uniqueid'] == null){// if the uniqueid is not equal to null, its "valid", regardless of what it is
        $link[] = array("url"=>$siteurl."?downloadid=".$single_download['id'], "name" =>$single_download["filename"]); 
       } else {
        $link[] = array("url"=>$siteurl."?downloadid=".$single_download['uniqueid'], "name" =>$single_download["filename"]);
       }
      }
     }
   foreach($link as $single_link)
   {
    // $product_list .= "\n\r ".$single_link["name"].": ".$single_link["url"]."\n\r";
    $cart_item->SetURLDigitalContent($single_link["url"], null, wpsc_cart_item_name());
    break;
   }
      //End of extra code  Vijay
Step 4. Now you are done .

What the above line of code will do ?
1. Create entry in WPSC_TABLE_DOWNLOAD_STATUS table unique id for download url .
2. Activate the URL
3. Send download URL information to Google to be displayed in Google checkout page after transaction complete. user really dont have to come back to your site to get the download link
4. Along with download URL Google will treat this product as digital digital product so no shipping issue  .
5. on top of all these this download  url information will be there in Google checkout mail send to buyer .

I hope wp-ecommerce will add this oprion to there code .


6 comments:

Christopher C. Parker said...

Do you know if this is still necessary with the current version of WP e-Commerce?

VJ said...

Not sure . didn't took a risk to update plugin .. but i will check it out in next implementation

Nancy L said...

Does the above code work for PayPal checkout as well?

Unknown said...

I would like to know if this works for paypal as well

VJ said...

I don't think this will work in paypal.. but might help you to do similar change to Paypal payment file

Codeslab said...

I am using Paypal for receiving payments. After checkout the user does not receive the download link in the mail. Please help.