signalpoint / commerce

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

Add to cart form does not display #9

Closed redamakarem closed 8 years ago

redamakarem commented 9 years ago

hello all, I am new to drupalgap but im really loving it. Thumbs up for all the hard work. I keep getting an error that says : failed to get form (commerce_cart_add_to_cart_form). Please let me know how to fix this issue. Thanks

scotthooker commented 9 years ago

Hey,

Where abouts do you get this error?

redamakarem commented 9 years ago

when i am viewing a product display node

signalpoint commented 9 years ago

@redamakarem In settings.js, set the Drupal.settings.debug = true; and report back here the messages that are output to the console.log(), thanks!

redamakarem commented 9 years ago

commerce_cart_add_to_cart_form - TypeError: Cannot read property 'length' of undefined VM70:789 drupalgap_form_load - TypeError: Cannot read property 'elements' of undefined

signalpoint commented 9 years ago

@redamakarem Did you do this step? https://github.com/signalpoint/commerce#known-issue

redamakarem commented 9 years ago

yes i believe i did

signalpoint commented 9 years ago

@redamakarem well it sounds like you might have to get your hands dirty then. Open up the commerce.js file and use dpm() along the way to see what is happening each step of the way through the commerce_cart_add_to_cart_form(). Report back here what you find please, more info: http://www.drupalgap.org/debug

This makes me think there is a possible syntax error in your commerce.js file, please verify the manual changes to the file didn't leave any syntax issues. Revert back to the original commerce.js file to confirm.

days4 commented 9 years ago

hello, i am building an commerce app using information provide on the page http://tylerfrankenstein.com/code/build-mobile-app-sell-products-with-drupal i followed all steps but when i press add to cart button it displays

_commerce_product_display_get_current_product_id - TypeError: Cannot read property 'length' of undefined WARNING: _commerce_line_item_add_to_order - no product_id i tried to debug and found that

 _commerce_product_attribute_field_names

in function _commerce_product_display_get_current_product_id is empty please help me to solve this problem

signalpoint commented 9 years ago

@days4 it has been a long time since I looked at this, but if I recall correctly, there is a custom Commerce DrupalGap module that needs to be installed on your site, and enable some service resources for it. Then during the system connect call, that module appens some important information to the system connect's json results, and is then set aside in the app. Then when it comes time to display the cart, the commerce.js file looks to those values provided by system connect to do some of the add to cart functionality. Make sure that module is installed, the service resources are enabled, and Drupal's caches have been flushed. Other than that I need someone to dig deeper into this here, this module is on a lower priority since it has minimal contributions/needs at this time.

days4 commented 9 years ago

hi, after further debug i found that there were some problem in commercee.js file in the function function _commerce_product_display_get_current_product_id() at line $.each(_commerce_product_display['field_productreference_entities'], function(pid, product) here field_productreference_entities is machine name of reference field now my form is displayed and on submiit it shows alert drupalgap_form_load -no callback function (commerce_checkout_shipping_view) available for form (commerce_checkout_shipping_view)

and product is added to cart but now on clicking continue to next step it shows alert drupalgap_form_load -no callback function (commerce_checkout_shipping_view) available for form (commerce_checkout_shipping_view) and displays a blank page

signalpoint commented 9 years ago

@days4 http://www.drupalgap.org/project/commerce_shipping?

GaryDeveloper commented 8 years ago

I was able to get the cart working for authenticated (logged in) users by making the following changes.

In your Drupal Intallation (web) go to admin/structure/types/manage/YOUR_PRODUCT/fields (my product is beer).

Find the row which indicates the FIELD TYPE COLUMN = Product Reference In that row, find the MACHINE NAME COLUMN and make a note of it. (mine is field_beer_products)

OPEN app/modules/commerce/commerce.js

CHANGE FROM var product_entities_field_name = drupalgap.settings.commerce.product_entities_field_name;

TO var product_entities_field_name = 'field_beer_products'; where field_beer_products is YOUR MACHINE NAME COLUMN

CHANGE FROM $.each(_commerce_product_display[drupalgap.settings.commerce.product_entities_field_name], function(pid, product) {

TO $.each(_commerce_product_display['field_beer_products_entities'], function(pid, product) {

WHERE field_beer_products_entities = YOUR_MACHINE_NAME_COLUMN_entities

SAVE COMPILE APP

If you are an authenticated user (logged in) on app - you should see your cart after adding products to the cart.

signalpoint commented 8 years ago

@GaryDeveloper Thank you for the detailed review of the bug. I've taken this a step further just now, and made commerce.js support any number of content types and product reference field machine names. Simply grab the latest commerce.js file, and use the drupalgap.settings.commerce configuration mentioned in the README for this project.

In your instance, you should only need to add this:

drupalgap.settings.commerce = {
    bundles: {
      beer: {
        product_reference_field_name: 'field_beer_products'
      }
    }
  };
signalpoint commented 8 years ago

I'm going to close this issue now. The project has been updated many times in the last few days, to the point where it can actually complete an order via Stripe. I'm going to close out this issue, if the problem persists, please open a new issue, thanks.

GaryDeveloper commented 8 years ago

Hi Tyler, So I've implemented the changes (I think). Something has gone awry. I'm not sure what. I'm getting add to cart and I can view the cart but now when I go to checkout I'm presented with a "Billing Information*" drop down that is blank and does not allow for adding any payment details. I have to admit I'm a bit confused. I updated the drupalgap commerce module. I did the patches on Drupal commerce_services. I updated the drupalgap addressfield module.

Now in admin/structure/services/list/drupalgap/resources I don’t have services_addressfield as a resource for which I can set permissions.

Once I understand everything and get it working, I’ll be happy to write an update to the tutorials and addendum to previous efforts for how to merge it.

Thanks for all you do.

Gary

signalpoint commented 8 years ago

Did you install the services_addressfield module in Drupal?

On Aug 27, 2016 3:23 PM, "GaryDeveloper" notifications@github.com wrote:

So I've implemented the changes (I think). Something has gone awry. I'm not sure what. I'm getting add to cart and I can view the cart but now when I go to checkout I'm presented with a "Billing Information*" drop down that is blank and does not allow for adding any payment details. I have to admit I'm a bit confused. I updated the drupalgap commerce module. I did the patches on Drupal commerce_services. I updated the drupalgap addressfield module.

Now in admin/structure/services/list/drupalgap/resources I don’t have services_addressfield as a resource for which I can set permissions.

Any suggestions?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/signalpoint/commerce/issues/9#issuecomment-242935796, or mute the thread https://github.com/notifications/unsubscribe-auth/AAo9pNY8stqa7XqpzTGJ1JGkOGnjJ539ks5qkI6kgaJpZM4C0Yff .

GaryDeveloper commented 8 years ago

I have now and it resolved the problem and presented the form. Not sure how I missed that. Installed services_addressfield module https://www.drupal.org/project/services_addressfield . Thanks for the tip!

GaryDeveloper commented 8 years ago

Now I'm getting the Billing Information form. I complete it and proceed. I arrive on the "Review Order" Page and it is blank except for a Review order header.

I can see in my debug output that the GET PUT for the order is successful but throws a ReferenceError: drupalgap_render is not defined at the end :

[INFO:CONSOLE(1)] "GET: http://my-domain.com/app-1/?q=drupalgap/order/20.json", source: file:///android_asset/www/jdrupal-7.0.4.min.js (1) 08-27 13:18:44.181: I/chromium(12688): [INFO:CONSOLE(1)] "200 - OK", source: file:///android_asset/www/jdrupal-7.0.4.min.js (1) 08-27 13:18:44.251: I/chromium(12688): [INFO:CONSOLE(1)] "entity_retrieve - success - ReferenceError: drupalgap_render is not defined", source: file:///android_asset/www/jdrupal-7.0.4.min.js (1)

THIS is the output that precedes it: "GET: http://www.mydomain.com/app-1/?q=drupalgap/order/20.json", source: file:///android_asset/www/jdrupal-7.0.4.min.js (1) 08-27 13:18:43.071: I/chromium(12688): [INFO:CONSOLE(1)] "200 - OK", source: file:///android_asset/www/jdrupal-7.0.4.min.js (1) 08-27 13:18:43.081: I/chromium(12688): [INFO:CONSOLE(1)] "PUT: http://www.mydomain.com/app-1/?q=drupalgap/customer-profile/7.json", source: file:///android_asset/www/jdrupal-7.0.4.min.js (1) 08-27 13:18:43.081: I/chromium(12688): [INFO:CONSOLE(2)] "{"status":"1","log":"","profile_id":7,"type":"billing","uid":1,"created":1472328722,"changed":1472328722,"commerce_customer_address":{"name_line":"Bill Meei","country":"US","thoroughfare":"113434 Jones Way","premise":"","locality":"Carlsbad","administrative_area":"CA","postal_code":""}}", source: file:///android_asset/www/jdrupal-7.0.4.min.js (2) 08-27 13:18:43.321: I/chromium(12688): [INFO:CONSOLE(1)] "200 - OK", source: file:///android_asset/www/jdrupal-7.0.4.min.js (1)

signalpoint commented 8 years ago

Update to the latest version of the drupalgap.min.js

On Aug 27, 2016 4:29 PM, "GaryDeveloper" notifications@github.com wrote:

Now I'm getting the Billing Information form. I complete it and proceed. I arrive on the "Review Order" Page and it is blank except for a Review order header.

I can see in my debug output that the GET PUT for the order is successful but throws a ReferenceError: drupalgap_render is not defined at the end :

[INFO:CONSOLE(1)] "GET: http://my-domain.com/app-1/?q= drupalgap/order/20.json", source: file:///android_asset/www/jdrupal-7.0.4.min.js (1) 08-27 13:18:44.181: I/chromium(12688): [INFO:CONSOLE(1)] "200 - OK", source: file:///android_asset/www/jdrupal-7.0.4.min.js (1) 08-27 13:18:44.251: I/chromium(12688): [INFO:CONSOLE(1)] "entity_retrieve - success - ReferenceError: drupalgap_render is not defined", source: file:///android_asset/www/jdrupal-7.0.4.min.js (1)

THIS is the output that precedes it: "GET: http://www.mydomain.com/app-1/?q=drupalgap/order/20.json", source: file:///android_asset/www/jdrupal-7.0.4.min.js (1) 08-27 13:18:43.071: I/chromium(12688): [INFO:CONSOLE(1)] "200 - OK", source: file:///android_asset/www/jdrupal-7.0.4.min.js (1) 08-27 13:18:43.081: I/chromium(12688): [INFO:CONSOLE(1)] "PUT: http://www.mydomain.com/app-1/?q=drupalgap/customer-profile/7.json", source: file:///android_asset/www/jdrupal-7.0.4.min.js (1) 08-27 13:18:43.081: I/chromium(12688): [INFO:CONSOLE(2)] "{"status":"1","log":"","profile_id":7,"type":"billing" ,"uid":1,"created":1472328722,"changed":1472328722," commerce_customer_address":{"nameline":"Bill Meei","country":"US","thoroughfare":"113434 Jones Way","premise":"","locality":"Carlsbad","administrative area":"CA","postal_code":""}}", source: file:///android_asset/www/jdrupal-7.0.4.min.js (2) 08-27 13:18:43.321: I/chromium(12688): [INFO:CONSOLE(1)] "200 - OK", source: file:///android_asset/www/jdrupal-7.0.4.min.js (1)

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/signalpoint/commerce/issues/9#issuecomment-242939066, or mute the thread https://github.com/notifications/unsubscribe-auth/AAo9pJTaCAIK35Pc1N89r8onDw9_jH0pks5qkJ4tgaJpZM4C0Yff .

GaryDeveloper commented 8 years ago

Cool! That resolved it and I'm getting a fully processed transaction through Stripe. Updated to latest drupalgap.min.js by downloading from here: https://github.com/signalpoint/DrupalGap

After extracting downloaded version of drupalgap-7.0.2 copied contents of the downloaded /bin folder to the app's www/bin folder and rebuilt app.

Also made sure that index.html references the updated file in www/bin <script type="text/javascript" charset="utf-8" src="bin/drupalgap.min.js"></script>

Thanks, Tyler!