Is it possible to add a product with a custom line item only to the recurring order?

I try to use the hook_commerce_order_presave(), but this ends with this error.

EntityMetadataWrapperException: Unknown data property cl_billing_license. in EntityStructureWrapper->getPropertyInfo() (Zeile 335 von /var/www/clients/client1/web1/web/drupal/sites/all/modules/entity/includes/entity.wrapper.inc).

CommentFileSizeAuthor
#2 commerce_license_billing_add_product1.patch2.46 KBAnonymous (not verified)
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anonymous’s picture

Category: Support request » Bug report
Priority: Minor » Critical

Today I created a recurring postpaid order in the tradtional way without interacting from my module. I just want to find out what happens if I add a produt to the recurring order which is created by the commerce license billing module.

After adding a product to the recurring order and clicked save I get the drupal error page. In the watchdog log I see now this error. The added product is not marked as a recurring product

EntityMetadataWrapperException: Unknown data property cl_billing_license. in EntityStructureWrapper->getPropertyInfo() (line 335 of /var/www/clients/client1/web1/web/drupal/sites/all/modules/entity/includes/entity.wrapper.inc). 

It's excactly the same behavior independent of the interaction of my module. It breaks the complete order for now. I marked this as critical, because the usage of the order page is not usable anymore.

Anonymous’s picture

Component: Miscellaneous » Code
Status: Active » Needs review
FileSize
2.46 KB

This patch solves the problem with the added not recurring products and also fixes the issue that commerce_license_billing break hook_commerce_order_presave(). Now I can use this hook to add products which are not recurring to the recurring order. I testet it in the postpaid mode.

I just notice if I edit a recurring order and click save the prices are set to 0. This occurs with original module version as with the patched one. Is this behavior known?

bojanz’s picture

Status: Needs review » Closed (won't fix)

The recurring order only has recurring line items, generated from the active licenses.
It is auto-generated and auto-updated, so no manual updates are allowed, and certainly not with non-recurring products.

You will need to go back and present your use case (what you're actually trying to accomplish) so that we can determine the correct
way to do it.

Anonymous’s picture

Thank you bojanz for your reply.

I try to explain what I want to do. I have 3 Products wich sell the same licence file. In my case it's a software plugin. The diffrence between the 3 products are the monthly recurring prices and the dependent comission amount.

Example Product Starter:

  • CLB recurring product: Product Starter monthly costs 0€
  • comission product: 2 % comission of the generated sales.
    (Customer sales amount made with my plugin: 1000€ calculated comission 20€)

Example Product Business:

  • CLB recurring product: Product Business monthly costs 99€
  • comission product: 1 % comission of the generated sales.
    (Customer sales amount made with my plugin: 1000€ calculated comission 10€)

The ideal programm flow should be:

  1. Customer decids which licence typ fits best for him an buy it. The bill and the license will be created and the price is set to 0 (postpaid). The license is valid for 1 month. This happens for example on the 1 May.
  2. On the 1 June the recurring order will be generated and my module adds the comission product with my calculated surcharge to the recurring order.
  3. Step 2 should be repeated until the licence gets canceled

The commission product is not a recurring one at the moment. That's all. So please give some advice to get that task working.

Anonymous’s picture

Category: Bug report » Support request
Priority: Critical » Minor
Anonymous’s picture

Status: Closed (won't fix) » Needs review
cac3a’s picture

I tried using this code in the patch and non-recurring products aren't still showing on license based orders. Is there another solution to add non-recurring products to recurring orders ?