2

I've a subscribe form on my website which i've got working(ish). So far i've got it asking user to input name, address, email, password and the subscription level + starter kit (from a list of promoted commerce items).

Once a user hits 'subscribe' the module creates a blocked user account (it will be activated by Paypal IPN listener if they pay), adds the commerce order (at checkout stage, thanks to Ryan for the script!) and then redirects to paypal for appropriate payment.

Up to this point i'm happy with everything except that the recorded order doesn't contain the address the user entered on the subscribe form and I can't figure out how do do this.

Has anybody managed it before, just point me in the direction of the function and i'll go from there.

Thanks

2

To record the address on the order, you must create a customer profile of the relevant type (billing information or, if you have Commerce Shipping on the site, shipping information), populate its addressfield value, and reference it from the order you've created. My recommendation would be to use the entity_metadata_wrapper() from the Entity API to manipulate those field values.

The addressfield on the customer profile you need to populate is commerce_customer_address, and the reference field on the order is commerce_customer_billing (or _shipping respectively).

  • 1
    Thanks a lot. I've never really used Entity metadata wrappers before. WOW! it's opened my eyes to a much easier way of handling data that's even slightly related to each other. – useyourillusiontoo Apr 13 '15 at 21:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.