signalpoint / commerce

The Drupal Commerce module for DrupalGap.
8 stars 10 forks source link

Line item fields on add do cart form. #10

Open b14r opened 10 years ago

b14r commented 10 years ago

Hi, I created a custom line item type and some fields for it. Those fields are checked for this option: "Include this field on Add to Cart forms for line items of this type." But, they don't appear on my phonegap application. I think it is because phonegap olny shows the commerce_product fields, am I right? If Yes, how can I fix it?

Thank you!

signalpoint commented 10 years ago

@brunomontibeller Correct, DrupalGap Commerce (as of now) doesn't understand custom line item types, and is only evolved enough to handle one product display type and product type. The dynamics shouldn't be too difficult, somebody just needs to get in there and write some code! ;)

For me personally this is low on my radar, I don't have any projects coming up with this need. If you're interested in contributing, please do! http://www.drupalgap.org/contribute

b14r commented 10 years ago

Right, I am going to work on it and maybe bring a new module for you guys :)

tennist commented 7 years ago

@bemontibeller did you ever figure out how to make DrupalGap Commerce read custom line item type fields? I am finding the need for this functionality and have been having trouble getting it to work. Any help would be appreciated.

signalpoint commented 7 years ago

@tennist I have not, I'd recommend looking at how I support custom entities (aka commerce customer profiles):

Using an approach similar to those links, any custom entity type can be supported. Each entity then needs a corresponding Drupal Services layer. Continuing with the Customer Profile example, here's the Services needs: https://www.drupal.org/node/2643530

tennist commented 7 years ago

I modified the code of this module to support purchasing giftcard products created the Drupal Commerce GC Module. It now checks the product type for giftcard and loads giftcard line-item fields instead of the product fields into the add to cart form. I also modified the submit function to create a giftcard_purchase line item instead of a product line item if the the product type is a giftcard. I also have added support for entity reference fields and textarea fields that are attached to products/giftcardss. If you are interested in this code I can provide it and hopefully someone can create a patch from it. I am not familiar with creating patches and my files currently contain all of the other previous patches.

This code also required a modification to commerce_drupalgap.module file the modifications was as follows:

Add line after line 35 as follows: $result->field_info_instances['commerce_line_item'] = field_info_instances('commerce_line_item');

I imagine someone could modify or add to these changes to support all custom line item types, however, I do not have that need at this time.