I'd like to restrict access to portions of a site to paid users only. And that's the only thing my site will sell. I want the signing up process to be extremely easy. In particular just prompt the user for billing info (address, credit card) and then they are done. In short, I don't want the process of filling a cart with an item then checking out.

However, I do want other portions of the ecommerce module. In particular the admin screens and purchase history shown in the user profile.

Is this possible? Is there an API I can use to initiate a transaction without the shopping cart?

Thanks, -Dave

Comments

Dave Cohen’s picture

Looking through some code, I see that store.module may contain what I need.

Can I simply call store_transaction_save(), passing in values for the keys in store_transaction_fields() and store_transaction_product_fields()???

If I take this approach, will it work in the current ecommerce module? Is it likely to work in future versions?

Again, thanks. This looks like a wonderful module.

lucidcarbon’s picture

Dave,

I'd like this functionality, too. Did you have any success with it or hear back from the developers?

Thanks!

Be well
-August

Dave Cohen’s picture

August,

I did not hear back. My site is still under development. When I have something fully working, if I can do it in a way that is generically applicable, I'll post code here.

Here's one of the more important pieces, creating a transaction containing a single product. It makes use of a feature of store's transaction validate and save methods, namely that you can pass in a field called 'nids' which is a list of product node ids.


function create_transaction_for_product($account, $node, $address) {
  // see store_transaction_fields()                                                                                                                                                                                                                                          
  $edit['uid'] = $account->uid;
  $edit['mail'] = $account->mail;
  // $edit['payment_method'] = $payment_method;                                                                                                                                                                                                                              
  $edit['payment_status'] = 1; // 1==pending                                                                                                                                                                                                                                 
  $edit['workflow'] = 1; // 1==transaction received                                                                                                                                                                                                                          
  $edit['gross'] = $node->price;
  // TODO: set expire, if not loaded automatically from product                                                                                                                                                                                                              
  $edit['nids'] = $node->nid;

  // address info                                                                                                                                                                                                                                                            
  $edit['billing_firstname'] = $address->firstname;
  $edit['billing_lastname'] = $address->lastname;
  $edit['billing_street1'] = $address->street1;
  $edit['billing_street2'] = $address->street2;
  $edit['billing_city'] = $address->city;
  $edit['billing_state'] = $address->state;
  $edit['billing_zip'] = $address->zip;
  $edit['billing_country'] = $address->country;

  if (store_transaction_validate($edit)) {
    $txnid = store_transaction_save($edit);
    return $txnid;
  }
  else {
    return false;
  }
}


sime’s picture

Component: other » -- other --
Status: Active » Closed (won't fix)

housekeeping - bit old this one

TerrenceLP’s picture

If one product, like a membership, etc..., I've used 'cart/review/' in the store config section under destination page after 'add to cart' has been clicked.

Running ec4 alpha 5, also can anyone show me an example on how to create a module for e commerce? I'm a module developer but can't seem to find good examples on how to interact with the product api, thank and hope the above helps!