Drupal Commerce Issue Queue

Document hook_redirect_form() generation

Mon, 01/19/2015 - 14:15

I'm implementing token billing + Card on File support for Commerce DPS, a payment processor popular in Australia / New Zealand. They have multiple payment processors & and token billing. The offsite processor (PX Pay) already works as a redirect method, and I've added the hosted processor (PX Post) in order to hijack its methods for token billing transactions.

When generating the payment screen in hook_redirect_form(), the $form and $form_state variables are not populated (called from drupal_get_form() in commerce_payment_redirect_pane_checkout_form()). As a result, if the user selects an existing card on file using the cardonfile elements provided, it seems harder than you'd expect to identify which card was selected during form submission.

If token billing is selected in Review form, I want to process it then and complete the order rather than redirect.

I'm about to clean up work for submission to #2397663: Token payment support ("card on file") and am creating this issue in order to reference while documenting the roundabout approach I took.

My workaround was:

  • Add a custom submit callback to the Continue button on the redirect screen
  • In this submit callback, create a transaction and stash the selected card in transaction data.
  • In the review form generation, look for the stashed transaction data and if so attempt to complete.
  • If completed, process payment and redirect user to the complete page.

I'm sure there's a better way, and I'd like to help document it for future devs (and to improve this approach).

Categories: Issue Queues

Prevent shopping cart form submission for completed orders

Mon, 01/19/2015 - 10:11

If you open the shopping cart form in multiple tabs and complete checkout in one of them, submitting the open shopping cart form from another tab will reset the order status of the completed order to "Checkout: Checkout." The shopping cart form does not have equivalent checks to the checkout router's that prevent access to checkout pages for an order after the order has progressed beyond a break point in the checkout process (loosely defined as a page with no back form button).

We should add an alteration to the shopping cart form that checks the order status during the form build process, since that's the earliest we can get to it, to prevent shopping cart form submission when the shopping cart order ID no longer matches a user's current cart order ID or when the order status indicates the order has progressed beyond a break point. To prevent submission of the shopping cart form in these cases, we'll use a redirect to whatever the current page is.

Categories: Issue Queues

How to Pay Others through commerce instead of receiving payments?

Mon, 01/19/2015 - 08:13

Hi,

I'd like to pay certain users.

Is it enough creating a line item type (product type) with negative (<0) price to keep consistency with Commerce?

I haven't done my homework yet (trying it) also I'd like to get some feedback / idea of others of this subject.

Thanks a lot!

Categories: Issue Queues

what&#039;s the available tokens in the &#039;Completion message&#039; checkout pane

Fri, 01/16/2015 - 23:48

I'm wondering what the available tokens in the 'Completion message' checkout pane are? I would like to generate a link to the purchased certificate and extracting the name of the purchaser as well as the purchased product. How can I do so?

Thank you,
Ron

Categories: Issue Queues

A video product for sell and purchase

Thu, 01/15/2015 - 22:34

I want to make a website that have videos as products. The products shown in views but after successful payment user can see the full video.

I am using video module for uploading videos
and using commerce module

Categories: Issue Queues

Product pricing rules fail with Rules 7.x-2.8 [use Rules 2.9]

Thu, 01/15/2015 - 07:30

OK, as of a day or two ago, one of my Commerce sites has started to apply no VAT to orders.

Symptoms:

  • VAT is applied correctly on Product display pages, and on the Basket page.
  • VAT is not applied at all on the Checkout Page, or after that in the checkout process.
  • If I add an empty coupon code to the order, the page refreshes and VAT is added correctly!

Stepping through the code with a debugger I just get hopelessly lost. I can't see the wood for the trees, there are so many function and method calls! I've learnt that you have to clear the cache too, otherwise the price field is simply loaded from cache, and not calculated from the base price plus taxes.

There aren't any errors reported in Drupal watchdog nor Apache logs.

Looking at the database, when I view the order's Basket, the line item commerce_unit_price_amount in the field_data_commerce_unit_price table includes VAT, and the commerce_unit_price_data includes all the VAT details.

But just going to the Checkout page causes the line item price to lose VAT, both in the price_amount and in the price_data.

Then refreshing the order by adding an empty discount coupon code adds in VAT to the display and to the line item data in the database.

Categories: Issue Queues

Update Price on Product Display Dynamically (AJAX?)

Wed, 01/14/2015 - 15:15

BACKGROUND:
I am using Commerce to create a site that sales banners, posters, signs, etc. The user of the site will enter the width, height and if the final piece will be 1 sided or 2. I have the width and height set as a line item type text field with the field type of decimal. I need the user to be able to enter whatever height and width they need as these times of products vary a lot in size and shape. Using a select field would need an infinite number of options as a banner could easily be 12.125" x 6.085".

To calculate the price for a product I am using Rules to take the WIDTH x HEIGHT to calculate square inches then taking that times 1 or 2 sided and the quantity. I have all that set up and when you hit the ADD TO CART button it does the math and looks good.

THE PROBLEM:
Now what I really need is to have the price on the Product Display change before the user hits ADD TO CART so that they know a cost before they put it in the cart. I have been trying to find ways to do this but not having much luck. Below are solutions I am thinking of but cannot find the answer to or a module that will help. Can anyone help point me in the correct direction?

1. Have the price update dynamically as the user changes the values (width, height, sides).

2. Have a CALCULATE COST button next to the add the cart (maybe using AJAX?) that the user can press after adjusting the width and height then if they are good with the price they can hit ADD TO CART. This option seems like it would be maybe the direction to go, but I do not have the expertise to know how to create such a button that does the Math using the RULE I set up.

3. Open to other ideas or suggestions...

Any help would be appreciated.

Categories: Issue Queues

commerce_customer_field_widget_form() must set #parents before calling field_attach_form()

Wed, 01/14/2015 - 10:44

Commerce calls field_attach_form() on a nested structure in only two places: commerce_cart_add_to_cart_form() and commerce_customer_field_widget_form().
Now, commerce_cart_add_to_cart_form() sets #parents as expected, but commerce_customer_field_widget_form() doesn't, which means that any commerce customer profile field widget (like the addressfield one) doesn't have accurate parents set, and is unable to access data in form state.

This breaks addressfield 7.x-1.0-rc1 on the order add/edit screen.

Categories: Issue Queues

Set an empty value for [&#039;exception&#039;][&#039;value&#039;] in the default User order history view.

Tue, 01/13/2015 - 04:43

Views adds all as a default exception value which creates a situation where this wildcard works in the default User order history view if the user has permission to view all orders or view all orders of type %type.

From views_handler_argument.inc:

<?php
  function is_exception($arg = NULL) {
    if (!isset($arg)) {
      $arg = isset($this->argument) ? $this->argument : NULL;
    }
    return !empty($this->options['exception']['value']) && $this->options['exception']['value'] === $arg;
  }
?>

Suggestion is just to tighten this up in commerce_order_ui.views_default.inc:

/* Contextual filter: Commerce Order: Uid */
...
$handler->display->display_options['arguments']['uid_1']['exception']['value'] = '';
...
Categories: Issue Queues

No line item validation when using &quot;update cart&quot; button

Fri, 01/09/2015 - 02:45

Hi,

I'm experiencing a validation issue when updating the line item on the cart page. If I set a product line quantity to -1 and hit update cart or continue button I see no validation errors and the fields are updated with the negative number but if I hit the remove button on the line item I see the validation errors and the field is not updated as expected.

Does anyone have any ideas why the validation is not working when using the update cart and continue button? Have tried using the default Drupal theme and disabling other modules but I am still experiencing the problem.

Cheers,
Tom

Categories: Issue Queues

&quot;Order balance&quot; doesn&#039;t match &quot;order total&quot; even if no payments made

Thu, 01/08/2015 - 21:59

I've been having an issue with a site where order totals aren't matching order balances in some orders (even if the order hasn't had any payments made on it yet, or if the payments are Purchase Orders, which don't affect the balance). At first I thought it was only ever $0.01 off, but now I see an order where the value is $0.15 off.

Regarding the $0.01 difference: I had a discussion (in IRC) with bojanz about this. He helped me figure out what is probably going on, which is that for the order total it seems the tax components are being rounded individually before being added to the total, whereas for the order balance they seem to be added together and then rounded up. Having two sales taxes applied leads to the extra penny if both are rounded up before being added together.

Anyhow, I wouldn't be surprised if I haven't given enough information here, but I'm just looking for a little guidance on where I might start looking. I am using commerce_discount with "%off Product discounts" and fixed discounts. I've attached a screenshot of one of the $0.01-discrepancy orders.

Thanks all!

Categories: Issue Queues

you have specified an invalid product for this reference field

Mon, 12/29/2014 - 08:26

When commerce product have missed reference to node, when saving node I see the message: you have specified an invalid product for this reference field because I use back referrence field (from node to commerce_product, that are in sync).

But when one node have many commerce_product entities linked, very hard to understand in which product there are problem.

Please add product SKU or product_id in this error message, for easily locating commerce product with problem.

Here is quick patch example - change:

<?php
          'message' => t('%name: you have specified an invalid product for this reference field.', array('%name' => $translated_instance['label'])),
?>

to:

<?php
          'message' => t("%name: you have specified an invalid product {$item['product_id']} for this reference field.", array('%name' => $translated_instance['label'])),
?>
Categories: Issue Queues

commerce_product_autocomplete throws PHP warning when no arguments are passed

Sat, 12/27/2014 - 15:25

Calling /commerce_product/autocomplete with no additional arguments generates the following PHP warning in dblog:

Warning: Missing argument 2 for commerce_product_autocomplete() in commerce_product_autocomplete() ...

Maybe a new access callback that just checks if there are sufficient arguments and return MENU_NOT_FOUND if not?

w

Categories: Issue Queues

Saving Orders in rules - not working with new fields

Fri, 12/26/2014 - 22:41

[Using Rules 7.x-2.6]

I've added some fields to Commerce Order at /admin/commerce/config/order/fields

I have a rules Action which saves some text to one of these new (text) fields on a new Order.
I use the standard "Save Entity" with "Force Immediate" option.

Condition:

   "IF" : [
      { "entity_has_field" : { "entity" : [ "commerce-order" ], "field" : "field_some_text" } },
:

Action (part):


   "DO" : [
:
:
      { "data_set" : {
          "data" : [ "commerce-order:field_some_text" ],
          "value" : { "value" : { "value" : "Some text", "format" : "filtered_html" } }
        }
      },
      { "entity_save" : { "data" : [ "commerce-order" ], "immediate" : 1 } },

But the new fields are never saved.
They are somehow "locally" present - I can fetch the object and print out the changed field from the new fields (in the SAME rule). But no commited change is taking place, i.e. no database change.

My workaround has been to create actions to set these fields:

<?php
function MYMODULE_set_some_text_field_action($order, $text)
{
$order->field_some_text['und'][0]['value'] = $text;
entity_save('order', $order);   
}
?>

which works fine (action called in rule).

But surely, the Rules alone should work?

Categories: Issue Queues

Commerce Q&amp;A and Discussions blocking my posts.

Fri, 12/26/2014 - 12:45

I attempted to post on Discussions (https://drupalcommerce.org/discussions) and my submission was silently blocked. Upon my second attempt I received a "triggered spam filters" notification. I went to Q&A (https://drupalcommerce.org/questions) to figure out what the problem was and I was silently blocked again. My posts contain no URLs, no reference to anything other than Commerce modules. I assume the CommerceGuys site is not blocking posts for containing words like product, sell, add to cart or discount?

Categories: Issue Queues

Add to cart form as fields in Views

Thu, 12/18/2014 - 04:06

I have three products referenced in one product display so that customers can choose to buy different sizes I am trying to create a product catalog in views using fields. Is the only way to show a functioning attributes select list and price updating functionality to use "Content: Rendered Node" or a similar non-fields method? Is there no way to have the add to cart form show up through selecting appropriate single fields/referenced fields?

Categories: Issue Queues

Commerce Price description is not translated

Wed, 12/17/2014 - 08:05

With i18n_fields enabled,
- set the description property of a Commerce Price field
- translate the description

The Commerce Price description is not translated when displayed in a form.

Categories: Issue Queues

Commerce Checkout process totally Ajaxified with Ctools

Thu, 12/11/2014 - 08:03

Howdi!

We’re building a professional movie streaming platform on Commerce. We’re already in the process of selling and deploying several platforms to established content distributors worldwide. We still have a few open questions regarding matters such as Checkout ajax callback submitting,handling, redirect and generally building these functionalities so that everything respects and utilizes commerce contrib code as Drupalwise as possible.

The Sandbox module project page: https://www.drupal.org/sandbox/juisi/2403251

The general idea of a streamlined checkout process.
  • Designed primarily for buying of digital goodies. (no shipping, billing data etc. needed)
  • Buy link activates the checkout dialog. Checkout form is rendered “on top” of the current page.
  • All required user input is gathered within the checkout payment pane form. (Would be really nice to also handle the multi-step pane form with this module)
  • Redirect to payment gateway or internal payment handling depending on the payment method, and redirect back to the initial node or admin defined return URL
  • In case an anonymous user hits the Buy link; get and render login/register form instead. Encapsulate Logintoboggan for example. User gets logged in (Ajax) and the checkout form is rendered instantly with the initial purchase.
  • Go with as few interaction steps and page loads as possible to create a nice user experience and improving the conversion rate of course..
  • Publish a sandbox/contrib module for "as general as possible" Ajax checkout handling. No hax/contrib patching. The Drupal Commerce people would hopefully find the module useful.
Ok, let's get into more detail..and problems

One big open question of how to proceed with wisdom; the form submit callback and handling the checkout procedure back to contrib / hook -system.

I’ve tested a few different approaches:

The first one i got ‘working’ is altering the form[‘action’] to point to a menu item path that directs the request to a callback striimin_checkout_submit_checkoutform with parameters that are included in the form[‘action’] value as URL parameters. My feeling of this solution is that it’s hacky and dirty, surely so because i don’t understand where and how the submission procedure jumps back to contrib / commerce hooks after our custom submit callback has run itself thru.

Also wondering the grittiness of the striimin_checkout_submit_checkoutform callback which needs to load the order (which was created in the ajax_checkout_get_checkoutform callback) and checkout_page and handle them to the drupal_get_form to get the checkout form array into the game. The array is not rendered and nothing is returned from the submit callback. Still somehow the checkout procedure continues with (seemingly normal) handling of external payment method module and its checkout hooks. So this ‘works’ with one kind of payment handling. Defining the redirect back to the initial node takes place in the payment gateway modules CALLBACK_commerce_payment_method_redirect_form. Refactoring all redirects (external and internal) into our module would be a nice feat.

But let’s say that we want to introduce a gift coupon (100% discount) and a ‘“no payment reguired” payment method option to handle the logic for this use case. The ‘“no payment reguired” -method would validate only if there is a 100% discount coupon applied. The validation is handled ok by the current solution, but how about the procedure after submit? I suppose, some custom logic is needed. Redirecting back to the initial node (if use-case necessary) and modifying some custom field values is in scope here. And potentially anything else. But where to put the code? Do we actually need a “no payment reguired” method and a corresponding module that will hook into action when this method is chosen?

Another, ‘not so working’ submit solution is to alter the $form['buttons']['continue'] -array with defining an ajax submit/validate callback functions. And leave the form[‘action’] to default state. This feels like a proper solution to me. The problem is that the submit (hook) function that is defined as the ajax callback gets the usual $form and $form_state as parameters ok, but does not seem to handle the procedure onward back to contrib functionality. The order is left ‘pending’ and it seems like the execution is stopped in this callback function.

Here as well, the need for a “no payment reguired” method and a corresponding module is needed to handle in-site logic. Repeating myself here, i don’t know how the naming convention works with machine names/module/hooks within Payment module Framework and is it even possible to write a module that hooks up only when this “no payment reguired” payment method is chosen by the user. I assume that “Basic payment method” and “no payment reguired” -methods are analogous ?

So, our challenges in a nutsell:
  • provide a functioning submit handler (callback) that can, depending on the payment method that the user has chosen, route the payment either to a payment gateway method (contrib module) or a “no payment reguired” payment method.
  • provide a custom module (According to Payment handbook https://www.drupal.org/node/1807610) to handle “no payment reguired” payments. This code should hook up when “no payment reguired” -method is chosen by the user. I do wonder if i can just configure a “no payment reguired” method thru Payment UI. Name it “Gift Coupon” and use the same naming in a custom module/hooks which will listen and hook up when “Gift Coupon” method is chosen by the user ??
  • provide a custom module and/or a hook that can handle redirecting after the order is completed. It should hook into action no matter which payment method is chosen. In other words, when a user returns to the site after a credit payment or the “no payment reguired” payment is completed, a redirect to the initial node is launched.

I will include parts of the code into this issue asap. Would you prefer a 'functioning' module to test against or is it fair enough to provide function references?

Any help is much help!
- Juisi@drupal.org

Categories: Issue Queues

Langcode problem with line item types, &quot;Commerce Donation&quot;, &quot;select or other&quot;

Wed, 12/10/2014 - 06:43

I've opened an issue at #2390379 (Commerce Donate) but this may be a wider problem on the one hand, and maybe a wider audience can be found here (as always I need a solution quickly as prod is live!)

The background is explained in #2390379 - basically after moving to prod. our donation form contains/returns (in $form_state):

<?php
$form_state['values']['line_item_fields']['commerce_donate_amount']['de'][0]['value'] is '250'
?>

instead of:

<?php
$form_state['values']['line_item_fields']['commerce_donate_amount']['und'][0]['value'] = '250'
?>

Looking at other entries in $form_state they ALL have the langcode 'und'.
Just as an example:

    [field] => Array ( [#parents] => Array ([line_item_fields] => Array ( [#fields] => Array
                                (
                                    [commerce_unit_price] => Array
                                        (
                                            [und] => Array
                                                (
                                                    [field] => Array
                                                        (
                                                            [entity_types] => Array
                                                                (
                                                                    [0] => commerce_line_item
                                                                )

                                                            [translatable] => 0
                                                            [settings] => Array
                                                                (
                                                                    [entity_translation_sync] =>
                                                                )

Similar for [commerce_product] ... and all other line-items.

But for commerce_donate_amount:

            [commerce_donate_amount] => Array
                                        (
                                            [de] => Array
                                                (
                                                    [field] => Array
                                                        (
                                                            [entity_types] => Array
                                                                (
                                                                    [0] => commerce_line_item
                                                                )

                                                            [translatable] => 1
                                                            [settings] => Array
                                                                (
                                                                    [precision] => 10
                                                                    [scale] => 2
                                                         

NOTE: [translatable] set to 1 (this is 0 on the test machine)

I'm thinking this is JUST a wrong setting somewhere, used during form generation (?).

The problem currently (as mentioned in #2390379) is that the form "accepts" a value of 250 (radio-button) from the form, but only displays 75 in the cart (which I think is the minimum value, or default). I list the rules errors in #2390379 - basically the value returned by the form cannot be found - because it's in 'de' and not 'und' I think.

Although 75 is displayed in the cart , in field_data_commerce_donate_amount " on the DB I have an entry 'de' and '250', e.g. entries like:

entity type:commerce_line_item,
bundle:commerce_donate,
deleted:0,
entity_id:293,
revision_id:293,
language:de,
delta;0,
commerce_donate_amount_value:1515.00

All help appreciated!
Oh, just to note, it IS a German site. Source language is EN, default is DE (as I remember...)

Categories: Issue Queues

Use a static cache in commerce_product_reference_field_extra_fields()

Mon, 12/08/2014 - 18:35

As with the issue in #2354561: Use a static cache in commerce_product_field_extra_fields() the function field_info_extra_fields() gets called a LOT and having Commerce's implementation of these hooks use a static cache shows a nice increase in performance.

I think it'd be beneficial to statically cache this function in the Product Reference module as well.

Attached is my first attempt at a patch, would love feedback.

Categories: Issue Queues