Hello
This is very weird. I have successfully created a product associated with a site, everything works fine. Whenever i want to create another product, the site is not generated, and during the checkout i am not asked to enter the subdomain name and so, and nothing is generated for the extra product. Is somebody facing the same issue here ?
Regards

Comments

doka’s picture

yes, I confirm this bug.

For one product it works, for a second one the domain name gets lost after I click on the save button at /purchase/site.

[edit]: the domain name from the second attempt is actually not lost, but is associated with the first site, I put previously into the card.

doka’s picture

There is something wrong at the submit function of the create_site_form (function uc_hosting_products_site_info_process) in the uc_hosting/products/inc/uc_hosting_products.pages.inc file

In its present form it just picks up the first product (model) from the uc_hosting_products table, and updates all the cart items belonging to this product with the domain name.

As a quick-and-dirty hack, replace line

if ($item->model == $site_model) {

with this one:

if (empty($item->data[site_data])) {

It will add the domain name to (all) items, where this parameter is empty.

If somebody confirms it, I'll provide a regular patch.

jayelless’s picture

I had the same problem of the Ubercart hosting integration working for only one product. I found that it would work for the first product defined, but not for any subsequent products specified. I do not believe that the change suggested above is the correct solution.

To me, the problem lies in the fact that the statement:

  $site_model = db_result(db_query('SELECT model FROM {uc_hosting_products} WHERE type = "sites"'));

in function uc_hosting_products_site_info_process (in the file uc_hosting_products.pages.inc) will always return only the first item from the set of items that might exist in the database table.

What is needed is a different query that will select the "relevant" entry from the {uc_hosting_products} table rather then the frst one. How do you get the relevant one? Well the answer is to encode the value into the form when it is being built (in function uc_hosting_products_site_info_form earlier in the same file). This can be done by adding the following lines:

  // Record the product model for later use
  $site_form['product_model']['#type'] = 'value';
  $site_form['product_model']['#value'] = $site_product['model'];

after the section that retrieves the site form and iterates round all the modules that might want to alter it.

Now the submit routine (function uc_hosting_products_site_info_process) has access to the product model directly, and so does not need to do a database lookup to find this information. Therefore the offending database query statement above can be replaced with:

  $site_model = $form_state['values']['product_model'];

and the site will now function for all specifed products of type=site.

jayelless’s picture

Category: support » bug
jayelless’s picture

Status: Active » Needs review
StatusFileSize
new1.14 KB

Patch for comment 3 above attached.

ergonlogic’s picture

Status: Needs review » Fixed

Committed, thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.