Issue Queues

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'commerce_order-9-0-0-und'

Drupal Commerce Issue Queue - Sat, 02/04/2012 - 13:03

After updating to the latest drupal core I'm getting the issue as per below error display, when adding a product in the cart as anonymous user or as admin (the only registered user at the moment).

I've noticed a similar issue with commerce_order was reported some time ago: http://drupal.org/node/1204210
But there is no solution to the issue outside tweaking with the database.
I'll try to do that, but I was wondering if anybody else experienced the same issue upgrading commerce to latest drupal core.

Needless to say that this issue is now blocking the webshop as no normal user can post an order.
Luckily we are in beta, but I need to fix this ASAP.

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'commerce_order-9-0-0-und' for key 1: INSERT INTO {field_data_commerce_order_total} (entity_type, entity_id, revision_id, bundle, delta, language, commerce_order_total_amount, commerce_order_total_currency_code, commerce_order_total_data) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8); Array ( [:db_insert_placeholder_0] => commerce_order [:db_insert_placeholder_1] => 9 [:db_insert_placeholder_2] => 74 [:db_insert_placeholder_3] => commerce_order [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => 0 [:db_insert_placeholder_7] => GBP [:db_insert_placeholder_8] => a:1:{s:10:"components";a:1:{i:0;a:3:{s:4:"name";s:10:"base_price";s:5:"price";a:3:{s:6:"amount";i:0;s:13:"currency_code";s:3:"GBP";s:4:"data";a:0:{}}s:8:"included";b:1;}}} ) in field_sql_storage_field_storage_write() (line 448 of /home/shop/modules/field/modules/field_sql_storage/field_sql_storage.module).

Categories: Issue Queues

How to handle failed authorization

Drupal Commerce Issue Queue - Sat, 02/04/2012 - 11:37

I'm implementing a payment gateway module which works fine as long the authorization is successful.

To route the callback from the credit card company I've set-up a success and a failure link as described in http://drupal.org/node/1040318.

<?php
url('checkout/' . $order->order_id . '/payment/return/' . $order->data['payment_redirect_key'], array('absolute' => TRUE))
url('checkout/' . $order->order_id . '/payment/back/' . $order->data['payment_redirect_key'], array('absolute' => TRUE))
?>

If an authorization is accepted it redirects to

<?php

CALLBACK_commerce_payment_method_redirect_form_validate
CALLBACK_commerce_payment_method_redirect_form_submit
?>
There I create a new transaction, store it and the checkout process is finished by commerce.

However if the authorization fails, non of the callbacks described in commerce_payment.api.php is called. The user is silently redirected back to the checkout page.

How can I do custom processing when the failure back link is called from the credit card company? I want to show the error message from the credit card company to the user.

For now I found this solution. But I don't think that it's really the intention doing it that way:

I implemented hook_commerce_checkout_router to get a hand on the data sent from the credit card company, store it in the $_SESSION variable and check in CALLBACK_commerce_payment_method_submit_form whether there's something stored in $_SESSION.

This is my code:

<?php

function commerce_datatrans_commerce_checkout_router($order, $checkout_page) {
    // check whether this is a failed payment atempt
    $data = $_POST;
    if (isset($data) && isset($data['status']) && $data['status']=='error' && arg(3)=='back' && arg(4)==$order->data['payment_redirect_key']) {
        $_SESSION['commerce_datatrans_error'] = $data;       
        //_commerce_datatrans_transaction_save($payment_method, $order, $data, COMMERCE_PAYMENT_STATUS_FAILURE);
    }
}

function commerce_datatrans_submit_form($payment_method, $pane_values, $checkout_pane, $order) {
   
    $data = isset($_SESSION['commerce_datatrans_error']) ? $_SESSION['commerce_datatrans_error'] : NULL ;
    if (isset($data)) {
        drupal_set_message(_commerce_datatrans_map_error_code($data['errorCode']), 'error');
        unset($_SESSION['commerce_datatrans_error']);
    }
   
    return array();
}
?>

How should this be implemented in a clean way?

Categories: Issue Queues

Implement a label callback for customer_profile entities.

Drupal Commerce Issue Queue - Sat, 02/04/2012 - 07:03

Currently there is no label callback for customer profiles:

<?php
    'label' => 'profile_id', // TODO: Update to use a custom callback.
?>
We can agree that just getting the id is not exactly useful, which is why commerce_addressbook invents its own label logic, and even provides its own alter function:
#1425784: Add ability to alter dropdown label.

So let's have a callback in Commerce that returns the "thoroughfare" value (street, basically) of the address.

Categories: Issue Queues

When default on product edits is to create a new revision, fieldset should be expanded.

Drupal Commerce Issue Queue - Sat, 02/04/2012 - 06:34

This is a followup on #1427144: Notice: Undefined index: revision in commerce_product_product_form() (line 77

Like the title says, when the default value for a product type is to create a new revision, the revision fieldset should be expanded, so that it's visible for admins that a new revision is being made.

Categories: Issue Queues

Another EntityMetadataWrapperException Problem

Drupal Commerce Issue Queue - Sat, 02/04/2012 - 05:56

Hello:

I have been trying to get rid of this bug for three days with no luck. It all begun when I run modules update via Drush. This triggered massive errors all over the place, from issues with paths (Unsupported operand types in path to "Store") to other kind of EntityMetadataWrapperException errors. It appears this error was introduced by one of those updated modules at random. (I suspect Entity API and Entity Reference are somehow the guilty ones) I slowly worked out all of them, but this one isn't going away. And it is killing me as it is keeping me from starting generating the final feature exports I need for the production server .

Shop Staging: In very advance stage of development (Almost ready to export features, build platform. 60 products, 30 product attributes with images, custom HTML5 widgets, 9 wholesale account types, retail, Quickbooks integration, etc) Renistalling core Drupal Commerce is propably impossible at this stage.

Versions

  1. Drupal Core: 7.x-dev
  2. Drupal Commerce: 7.x-1.x-dev
  3. CTools: 7.x-1.x-dev
  4. Entity API : 7.x-2.x-dev
  5. Rules : 7.x-2.0+15-dev
  6. Views : 7.x-3.x-dev
  7. Address Field: 7.x-1.x-dev

Other System Info:

  • Multi-site set up (3) thorugh right now working on the master one from which I will spawn the Featues for the smaller sites
  • Uses Entity Reference often: 7.x-1.x-dev
  • Using UUID: 7.x-1.x-dev
  • Originally this was a site started with Commerce Kickstar profile back in June. Because I am building a custom profile for this project, at one point I side-graded to a standard Drupal install so I could have a clean "profiles" folder.

THE ERROR

Note: In case it matters (which I doubt), I posted the error as it was printed in both the page and the log, which it includes three massive blank space gaps between the last three lines. To save space for this post I added "[BLANK SECTION]" manually instead.

EntityMetadataWrapperException: Unknown data property field_product. in EntityStructureWrapper->getPropertyInfo() (line 339 of /var/www/drupal/sites/all/modules/contrib/entity/includes/entity.wrapper.inc). Backtrace:
EntityStructureWrapper->getPropertyInfo('field_product') entity.wrapper.inc:396
EntityStructureWrapper->get('field_product') entity.wrapper.inc:417
EntityStructureWrapper->__get('field_product') commerce_product_reference.module:298
commerce_product_reference_entity_view(Object, 'node', 'block', 'en')
call_user_func_array('commerce_product_reference_entity_view', Array) module.inc:819
module_invoke_all('entity_view', Object, 'node', 'block', 'en') node.module:1388
node_build_content(Object, 'block', 'en') node.module:1285
node_view(Object, 'block') views_plugin_row_node_view.inc:103
views_plugin_row_node_view->render(Object) views_plugin_style.inc:310
views_plugin_style->render_grouping_sets(Array) views_plugin_style.inc:273
views_plugin_style->render(Array) theme.inc:51
template_preprocess_views_view(Array, 'views_view') theme.inc:1008
theme(Array, Array) views_plugin_display.inc:2526
views_plugin_display->render() view.inc:1119
view->render() views_plugin_display_block.inc:53
views_plugin_display_block->execute() view.inc:1182
view->execute_display('block') views.module:643
views_block_view('product_block_coda-block')
call_user_func_array('views_block_view', Array) module.inc:795
module_invoke('views', 'block_view', 'product_block_coda-block') block.module:853
_block_render_blocks(Array) block.module:674
block_list('sidebar_first') block.module:318
block_get_blocks_by_region('sidebar_first') block.module:268
block_page_build(Array) common.inc:5578
drupal_render_page('

       
  [BLANK SECTION - 30 lines]
 
 
') common.inc:2582
drupal_deliver_html_page('

       
   [BLANK SECTION - 30 lines]
 

') common.inc:2470
drupal_deliver_page('

       
   [BLANK SECTION - 30 lines]
 
', '') menu.inc:532
menu_execute_active_handler() index.php:21

Where the errors happen:

  1. Front Page or any page with views that uses product content type
  2. Views administration as an AJAX error when trying to work with a view that has product content types in it.
  3. When running cron either via UI or Drush

Solutions tried:

I followed some of the solutions being suggested by rfay and DC crew :

Since I have this whole thing seriously backed up, I tried a few things a little bit on "wilder side" , not so much to find a solution but to see if they could point me out towards the culprit:

  • I tried reinstalling both the Commerce Product Reference and Commerce Line Item using Devel and as expected, it triggered massive errors. Restored from back up.
  • I tried to manually compare an older database with a copy of the latest version using the SQL schema version as exported by Schema, but I did not see any major differences in table structure.
  • Checked the System table for misconfigured paths, disabled items (0) and the such, but I found nothing out of order.

Closing Oddities

  • Checking my schema structure I found at least 27 fields (Field_SQL_Storage) that have mismatching entries, two per field. I doubt this would be in any way related as none are critical and they were already there before all this happened. All 27 fields have the exact same error.
    Example:
    indexes field_dyb_fabric_1_target_entity: missing in database
    indexes field_dyb_fabric_1_target_id: unexpected (not an error)
  • I installed and uninstalled some minor modules that I had tried in the pasr and perhaps I forgot to uninstall prior to removing them from contrib: Commerce Coupon, Commerce Product Bundle. I read a couple of comments indicating these modules had some issues when not properly uninstalled. They all checked out and had been uninstalled properly.

If there was one time in the last 3 1/2 years that I have been truly of the edge as far as needing some assis, this is the one.

Thanks

Categories: Issue Queues

hook_commerce_payment_order_paid_in_full() does NOT fire due to DrupalCommerceEntityController::save bug

Drupal Commerce Issue Queue - Fri, 02/03/2012 - 15:56
The symptom

* place an order, in my case with payment method commerce_cheque (but any should give this error)
* mark the cheque as paid
expected
* hook_commerce_payment_order_paid_in_full() should fire and (in my case) change order status
experienced
* hook does not fire

The cause

(wow, this was a nasty bug to track down...)
* payment changes $transactio->status from pending to success
* DrupalCommerceEntityController::save fires hook_commerce_payment_transaction_update() before it clears entity cache.
* So commerce_payment_order_balance($order) loads the old $transaction which is still pending
* order balance is calculated wrong
* and hook not fired

The cure

see attached patch:
hook invocation should come after cache update.
i think it should also come after releaseLock() - but a DrupalCommerceEntityController guru might consider this.

Categories: Issue Queues

Bug with address field without address

Drupal Commerce Issue Queue - Fri, 02/03/2012 - 14:06

This might sound a bit silly, but even though the addressfield is called addressfield, you don't actually have to use it for storing addresses, you can limit it to storing name and/or company name. It happened to fit my use case, since I don't need to store addresses during checkout I thought it was easier to just use it for storing the name which I did need.

Doing this I've found this strange bug, that I'm guessing has something to do with the way customer profile saves the address. I remember that some strange things are going on there.

Anyways the actual bug is that if you don't have the address part enabled in the address field, the addressfield won't actually save the name. What's worse is, that is a name is already stored (temporarily turning the address on, entering data, turn address off and go back), the name will be deleted if the form is submitted again.

So clearly something whacky is going on.

Ryan do you have any hunches, been a long time since I looked at the customer profile and addressfield interaction.

Categories: Issue Queues

Abbreviate US States

AddressField issue queue - Fri, 02/03/2012 - 14:02

Is there any way to abbreviate the output of the state fields? In other words, make Rhode Island display as RI or Maine display as ME?

Categories: Issue Queues

Views "In Cart" Not Updating on add/remove items from cart

Drupal Commerce Issue Queue - Fri, 02/03/2012 - 12:29

NOTE: Using Views 7.x-3.1

Not sure what's happening here, but I have attempted to use the In Cart block view to provide a block across the store I am working to indicate the number of items the user has in their cart (a pretty normal implementation of this feature I believe).

I've added screenshots below depicting the scenario.

The Items in Cart is placed as a block at the top of the content and is available on all pages.

Prior to placing any items in the cart the block doesn't show or indicate any items in the cart.

After placing any item in the cart, the total reflected in the block doesn't change.
After removing items from the cart, the total reflected in the block doesn't change.
Emptying the cart still shows the same number of items in the cart.

I'm baffled... could this be a bug in the commerce and/or views modules?

AttachmentSizeStatusTest resultOperations Screen shot 2012-02-03 at 12.05.35 PM.png71.44 KBIgnored: Check issue status.NoneNone Screen shot 2012-02-03 at 12.05.51 PM.png110.04 KBIgnored: Check issue status.NoneNone Screen shot 2012-02-03 at 12.06.18 PM.png271.18 KBIgnored: Check issue status.NoneNone Screen shot 2012-02-03 at 12.06.37 PM.png59.03 KBIgnored: Check issue status.NoneNone Screen shot 2012-02-03 at 12.06.53 PM.png43.56 KBIgnored: Check issue status.NoneNone Screen shot 2012-02-03 at 12.07.07 PM.png644.67 KBIgnored: Check issue status.NoneNone
Categories: Issue Queues

Error during install

Drupal Commerce Issue Queue - Fri, 02/03/2012 - 11:50

Hello, I'm getting an error during install of the new version of Commerce:

Running installer (takes a minute, check cpu activity) ...                                                                                                   [ok]
No tables to drop.                                                                                                                                           [ok]
Starting Drupal installation. This takes a few seconds ...                                                                                                   [ok]
WD rules: The reaction rule Example payment (commerce_payment_commerce_payment_example) fails the integrity check and cannot be executed. Error: Unknown     [error]
action commerce_payment_enable_commerce_payment_example.
WD theme: Theme key "image_formatter" not found.                                                                                                             [warning]
WD theme: Theme key "image_formatter" not found.                                                                                                             [warning]
The Date API requires that you set up the site timezone and first day of week settings and the date format settings to function correctly.                   [warning]
You are about to DROP your 'provider_dev' database and then CREATE a new one. Do you want to continue? (y/n): y

I'm using this make snippet (among other things):

projects[addressfield][subdir] = contrib
projects[admin_menu][subdir] = contrib
projects[ctools][subdir] = contrib
projects[entity][subdir] = contrib
projects[rules][subdir] = contrib
projects[views][subdir] = contrib
projects[views_bulk_operations][subdir] = contrib
projects[commerce][subdir] = contrib
projects[commerce_paypal][subdir] = contrib
projects[commerce_features][subdir] = contrib

And this dependency code during install:

; ==============================================================================
; ============== START SNIP: commerce_kickstart.info ===========================
; ============== http://drupal.org/project/commerce_kickstart ==================
; Install other contributed modules first.
dependencies[] = addressfield
dependencies[] = admin_menu
dependencies[] = ctools
dependencies[] = entity
dependencies[] = entity_token
dependencies[] = rules
dependencies[] = rules_admin
dependencies[] = views
dependencies[] = views_ui

; Install the Commerce modules.
dependencies[] = commerce
dependencies[] = commerce_ui
dependencies[] = commerce_cart
dependencies[] = commerce_checkout
dependencies[] = commerce_customer
dependencies[] = commerce_customer_ui
dependencies[] = commerce_line_item
dependencies[] = commerce_line_item_ui
dependencies[] = commerce_order
dependencies[] = commerce_order_ui
dependencies[] = commerce_payment
dependencies[] = commerce_payment_ui
dependencies[] = commerce_payment_example
dependencies[] = commerce_price
dependencies[] = commerce_product
dependencies[] = commerce_product_ui
dependencies[] = commerce_product_pricing
dependencies[] = commerce_product_pricing_ui
dependencies[] = commerce_product_reference
dependencies[] = commerce_tax
dependencies[] = commerce_tax_ui

; ==============================================================================
; ================ END SNIP: commerce_kickstart.info ===========================

Any ideas?

Mike

Categories: Issue Queues

Can't configure Feeds mapper

AddressField issue queue - Fri, 02/03/2012 - 09:41

It is not possible to configure Feeds mapping, because address fields are not available in the target scrollbox in the admin/structure/feeds/edit/*/mapping page.

Categories: Issue Queues

Notice: Undefined index: revision in commerce_product_product_form() (line 77

Drupal Commerce Issue Queue - Fri, 02/03/2012 - 05:27

There is a minor flaw in the commerce product form.

Categories: Issue Queues

Warning message after upgrading to Drupal 7.12 and Commerce 7.x-1.2

Drupal Commerce Issue Queue - Fri, 02/03/2012 - 04:37

Hi Rszrama and Commerce team-

Just updated to Drupal 7.12 and Commerce 7x 1.2 and got this warning message and a notice-

Warning: array_keys() [function.array-keys]: The first argument should be an array in drupal_schema_fields_sql() (line 6842 of /home1/centerq8/public_html/includes/common.inc).

and

Notice: Undefined property: stdClass::$field_slideshow_image_height in field_sql_storage_field_storage_load() (line 360 of /home1/centerq8/public_html/modules/field/modules/field_sql_storage/field_sql_storage.module).

Notice: Undefined property: stdClass::$field_slideshow_image_width in field_sql_storage_field_storage_load() (line 360 of /home1/centerq8/public_html/modules/field/modules/field_sql_storage/field_sql_storage.module).

these warnings and notices did not come until after Commerce update.

The interesting thing is - on the page for the slideshow image width and height notice- there is not slideshow on the page that the Drupal log references via link = so I have no idea what this notice refers to

Not sure what they mean but wanted to let you know.

Thanks for all the great work!

Aaron

Categories: Issue Queues

Redirect/change checkout complete page

Drupal Commerce Issue Queue - Thu, 02/02/2012 - 20:18

Maybe this should be straightforward but I can't seem to figure it out right now...
How do I redirect/change the checkout complete page without killing any puppies?

Say, upon checkout completion, I want to redirect to a particular node or the order summary at /user/%/orders/%?

Categories: Issue Queues

Drupal commerce interacts with "Create content"?

Drupal Commerce Issue Queue - Thu, 02/02/2012 - 18:27

Dear All,
I want build a system like this:
1. Medical records system:
- Profile (user) has all information that rarely changed of patient. Can do with Drupal 7 core or profile 2. That's enough.
- Consultation (content type): Each profile )= patient) can have many times go to hospital, each time = one consultation). We can use relation module to do this: content --> user "direction relation". That's ok.
* Price of each consultation is 10 USD (that means each node is corresponding 10 USD).
- Many other content types: Untra-sound, X-ray, ...
* Price of each above "node": x USD, y USD, ...
- Some content types do not have a hard price. Example: test, prescription of the doctor.
* In a test paper has many item: Gluco test, Bilirubile test, cholesterol test, .... In prescription paper has many items that may be appeared: paracetamol, loratadine, ... (1-10 medicines of 1000s medicines can be chosen). So, each node likes this may be have different price (the price made by various items)
- Some other content types do not have a price ("free").

About how to collect all nodes into a perfect Patient File? That will be done by using relation module
About how to view nice nodes, nice forms? That will be done by various modules. But I still do not know what is the best choice?

2. Commerce System
- "Products - Goods" are medicines, disposables, consultations, X-ray, ...
- All reports, tasks can be done by views and other contributed modules. No need code.
I have learned Drupal Commerce. That's the best for this.
- But have a BIG PROBLEM: How to collect (interact) 2 system together? That means: when we create a "consultation" node, one order will be create too. And a "product" will be add to this order.
After that, when a X-ray is created, a "X-ray product" will be add this order. One more X-ray created, one more "X-ray product" will be add, ...
And an important issue: when a prescription be done, each item with its number (medicine) will be add to the order (of right patient).

If we required good performance, Is it better or not when 2 system should be lived in separate servers. What is the best solution for this?

Many thanks,
P/S:
Dear DC team,
if this issue is not should here, please remove it.

Categories: Issue Queues

How do I show user account profile fields in Profile2?

Profile 2 Issue Queue - Thu, 02/02/2012 - 11:58

I have an extensive set of fields I created for our user accounts in Configuration > People > Profiles ( http://somatics.org/admin/config/people/profile settings )

These include fields that users need to fill in to join the site, and fields I need to be shown in users' public profiles. I very much want to use Profile2 to get all the various mature functionality of community oriented profiles it provides. However, I want to use the fields I've already created (I have thousands of users who have provided information in these fields) -- and they do not show up under Profile2 as I had hoped.

(Plus, I need these to be fields they're compelled to fill in when they create their accounts.)

Is there a solution to this?

Categories: Issue Queues

State (as administrative area) needs a context

AddressField issue queue - Thu, 02/02/2012 - 09:17

The standalone word state is used in various module as the label of a status column or such.

I think it's fair to assume the number of uses of the word State as an administrative area is much lower, so the context identifier needed to disambiguate should be put there.

AttachmentSize patch-addressfiles-state-context.patch1.11 KB
Categories: Issue Queues

Improve description for "manage display" link for injected fields

Drupal Commerce Issue Queue - Thu, 02/02/2012 - 06:18

On the "Manage display" tab of a product display, there may be a list of fields that are being injected from the product entity.
Currently the description underneath this field says "Modify the settings for this field on the product display configuration."

This might be a bit confusing, since the link is pointed to the "manage display" tab of the product entity, but the 'product display configuration' wording seems to suggest this is a 'product display' setting, rather than a 'product entity' setting.

Categories: Issue Queues

Missing unit price and total figures

Drupal Commerce Issue Queue - Thu, 02/02/2012 - 06:11

In the User invoice these are missing.

Categories: Issue Queues

Localisation of attributes in add to cart form not performed

Drupal Commerce Issue Queue - Thu, 02/02/2012 - 02:20

In order to reproduce you should:

- Create a 'Size' vocabulary
- Create two products with different sizes
- Create a product display which refers to the two products.

A drop down menu will then appears to let the user choose the size of the product.

Then in order to localize the website you can use i18n, entity_translation and the title menu. You are now able to translate taxonomy terms, but the drop-down menu is not using the localized terms.

Categories: Issue Queues
Syndicate content