I am using ubercart 2.2x and the flatrate shipping method. I have several flat rate shipping methods set up. I installed this module, and when I click on the tab and then check off a couple of shipping methods and click save, everything happens normally (no errors) but my settings aren't saving (all the boxes are then unchecked again).

Any ideas?

Thanks.

Comments

nanopatch’s picture

I got exactly the same problem, can you please take a look at it? It's an urgent bug for our store.
thank you in advance

winnie80’s picture

hi all,
it has been almost a year now since last comment
any one solve this saving problem?
thanks

daniele_v’s picture

Hi all,
I've exactly the same problem.
At first look to the code, seems that the checked values aren't saved in $form_state array.
Usually these operations should be done by Drupal javascript (I guess), but I'm not a Drupal programmer and nor PHP programmer.
If I find out why these values are not saved in the array, I will post here the solution.
Regards

daniele_v’s picture

I modified these code lines and now it saves the settings... but I cannot understand beacuse even if I set only a Shipping Method for a Product Class, in order checkout with items of that product class, I can still choose among all methods.

uc_product_quote.admin.inc at row 41:

// Retrieve modules that impliment shipping methods.
$methods = module_invoke_all('shipping_method');
foreach ($methods as $mid => $method) {
//Clear flatrate options
$fr_options = array();
// If the method is enabled
if ($method['enabled']) {
// Convert mid from "flatrate_nn" to "nn"
//$mid = str_replace('flatrate_','',$mid);

// Keep array of enabled method id's
// Retrieve an array of methods enabled
$rs_flatrates = db_fetch_array(db_query("SELECT mid, label FROM {uc_flatrate_methods} WHERE title = '%s'", $method['title']));
$fr_options[$rs_flatrates['mid']] = $rs_flatrates['label'];

$mids[] = $mid;

// Container for each methods services
$form[$mid] = array(
'#type' => 'fieldset',
'#title' => $method['title'],
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);

// Retrieve an array of services already selected for this method
$services = unserialize(db_result(db_query("SELECT services FROM $table WHERE $primary_key = $primary_key_type AND method = '%s'", $id, $mid)));

// If no services have previously been selected
if (!$services) {
$services = array();
}

// List of methods services to restrict for the product
$form[$mid][$mid] = array(
'#type' => 'checkboxes',
'#title' => t('Services'),
'#default_value' => $services,
'#options' => $fr_options, //$method['quote']['accessorials'],
);
}

rickupdegrove’s picture

#4 breaks FedEx shipping quotes but fixed Flat rate save settings checkbox works.

However this module just doesn't seem to work as described. With or without the #4 both Flat rate and FedEx are available on checkout.

That is to say with with 1 or 0 shipping options applied on a per product basis, both shipping options are available and one must still be selected to be applied at checkout which is exactly how the store worked before this module.

tomfallowfield’s picture

I'm getting the same issue.

daniele_v your code allows the form to save the first flat rate method, but changes to subsequent methods do not save.

any ideas?

thanks

tomfallowfield’s picture

I've fixed part of my problem.

The problem (or rather 'a problem') seems to be that the table uc_product_quotes has nid as a primary key. This throws a duplicate entry error when you try and have more than one shipping method per product (for this the table would need to have several entries with the same nid, not possible if it's the PK).

A quick "alter table uc_product_quotes drop primary key" combined with daniele_v's patch in #4 has fixed this. I can now have three flatrate shipping methods, and changes to the checkboxes on product level now gloriously persist.

I now need to work out how to make it actually stop the unrequired methods showing up on the checkout page.

I'll let you know if I work it out.

tomfallowfield’s picture

Cracked it. Hope this helps.

I created a simple function to check if the given shipping method is enabled for ALL the products in the current order.

In the Shipping Quote Settings (admin/store/settings/quotes/methods/flatrate) I added a condition to each method, under "Execute Custom PHP" like this:

return allowMethod($method);

The allowMethod function (in my case in a custom module) looks like this:


// check if the given shipping method is enabled for ALL the products in the current order

function allowMethod($method){
	$output = true;
	foreach(uc_cart_get_contents() as $product){
		$matches = db_fetch_array(db_query("SELECT nid FROM {uc_product_quotes} WHERE method = '" . $method["id"] . "' AND nid = " . $product->nid . ";"));
		if(!$matches){
			$output = false;
		}
	}
	return $output;
}

stesind’s picture

Does anyone had a look on this: http://drupal.org/node/1182786 ?

muzunova’s picture

Hi, if I manage to get this working, it will save my life! So thanks all for the wonderful feedback on a great module.

I'm still learning so not sure where to apply the "alter table uc_product_quotes drop primary key" line, Tom, can you help? I've managed to go as far as enabling the saving of one flat rate (per Daniele's fix) but I need at least six or more options per product enabled...

Thanks in advance for your help!

Marina