Option not to show product attributes

Rainman - July 3, 2009 - 00:50
Project:UC Upsell
Version:6.x-1.15
Component:Miscellaneous
Category:feature request
Priority:normal
Assigned:torgosPizza
Status:closed
Description

would it be possible to not have the related product attributes show up in the block, rather displaying as they are in the catalog view. I have some text entry attributes and it really makes the teaser look odd for a related product preview.

#1

torgosPizza - July 4, 2009 - 17:42

Well, the only issue here is that it would require you to use the Cart Links method of adding them to your cart instead. Either that, or you would just hide the entire Add to Cart form (and require users to click to the product instead). I'm not sure which is best, although I'm inclined to hiding the Add to Cart form - and if I do that, should it be a global option, or only switch if a product contains attributes? What do you think?

#2

Rainman - July 6, 2009 - 20:47

Well for constancy's sake I would say make it global.. once again it would look odd to have some show up with the button and others not just as the occasional attribute looks odd now. Really I think not having the Add to Cart form would be preferred overall for myself anyhow.

Thanks!

#3

torgosPizza - July 19, 2009 - 01:04
Assigned to:Anonymous» torgosPizza

I still need to focus on this. Hopefully in the next few days. Sorry for the delay.

#4

Rainman - July 20, 2009 - 22:33

A question about moving to cart links method or hiding the form, would that change the List Price showing also (or be something configurable) I find that kinda odd looking too on my site anyhow, example: $0.00List Price: $1.00

Thanks!

#5

torgosPizza - July 21, 2009 - 03:04

No, they are separate issues. The "List price" is part of the fields being displayed by your Store settings. Go to admin/store/settings/products/edit/fields and uncheck the List price field.

#6

Rainman - July 21, 2009 - 10:35

Well I do want the List Price to show up in the product details, but not in the upsell block, just as with the product attributes. I guess what I am looking for is for the upsell block to look just like the product grid view in that regard.

Thanks!

#7

torgosPizza - July 21, 2009 - 20:32

Hmmm. Okay. In that case you're probably better off just overriding the theme function. I don't think I can account for every product field that could ever exist - it should all use the same configuration settings. Look up overriding theme functions on drupal.org.. I can provide guidance for this particular model when you need it.

#8

Rainman - August 1, 2009 - 04:42

Okay, began to look into overriding theme and looking into the code, it occurred that the List Price portion was very easy to remove.. I just removed the whole list price section from the uc_upsell.module:

  removed as code has changed, see later post

Seems that part would be easy enough to just add another flag somewhere in the admin config to exclude it.. anyhow I am good on that one now.

digging deeper on the attributes, see what I come up with.

#9

torgosPizza - July 21, 2009 - 23:33

The attributes are part of the add to cart form. So, I forget where it takes place, but I'm not 100% sure that's part of the theme function. I can't check right now but I can look into it later tonight. If it is in the theme function then you can simply remove it, or replace it with a cart link.

You know what, perhaps I will add the cart links back in as an option. This would alleviate this type of issue. It's not quite as elegant as keeping the Add to Cart buttons in there, but I think there has to be a compromise somewhere for this to work for everyone.

#10

Rainman - July 22, 2009 - 01:58

Ahhh.. ok now I see, if I remove the cart form part, the attributes go away also, this part:

  $product['add_to_cart'] = array(
    '#value' => theme('uc_product_add_to_cart', $node, TRUE, FALSE),
    '#access' => $enabled['add_to_cart'],
    '#weight' => $weight['add_to_cart'],
  );

now I also see that is themed, so hoping that can be tweaked to leave the Add to Cart but not the attributes

#11

torgosPizza - July 22, 2009 - 03:14

Yeah exactly, the theme function for Upsell just themes the add to cart form, along with other elements. So you can do it that way. It's not the most user-friendly because you have to know how to override theme settings. I guess anything I can do to make it more intuitive for novice users would be a plus.

#12

Rainman - July 22, 2009 - 03:34

Well you have my full support there, novice user would be me!:).. but trying to come up to speed. digging through ubercart, I think what would work would be using the simpler uc_catalog_buy_it_now_form, but I have no idea how to implement that in place of the theme('uc_product_add_to_cart'... either.

#13

Rainman - July 22, 2009 - 11:34

Alrighty, I figured out how to change the form. at the bottom of uc_upsell.module the following lines:

  $product['add_to_cart'] = array(
    '#value' => theme('uc_product_add_to_cart', $node, TRUE, FALSE),
    '#access' => $enabled['add_to_cart'],
    '#weight' => $weight['add_to_cart'],
  );

are replaced with:

$product['add_to_cart'] = array('#value' => drupal_get_form('uc_catalog_buy_it_now_form_'. $node->nid, $node));

this is just exactly how I want it all to work (along with removing the List Price earlier).. maybe not for everyone, but I'm a happy camper now. Hopefully all this will be of use to someone else too.

Thanks for your guidance!

#14

torgosPizza - July 29, 2009 - 00:22

Cool. Do you have a screenshot or a live site where I can see what that looks like? I'd like to implement this feature but won't know what I'm looking for without an example :) Thanks!

#15

torgosPizza - July 30, 2009 - 02:43
Status:active» fixed

I tested this out in my local sandbox and it works great. I just committed to Dev a version that includes a new option (a checkbox that is Disabled - set to FALSE - by default) that allows you to use a Buy Now button instead of the usual Add to Cart. Please take a look once the Dev packaging script runs and let me know what you think.

#16

Rainman - July 31, 2009 - 03:11

I tried installing latest dev, but received the following errors:

warning: array_merge() [function.array-merge]: Argument #2 is not an array in /var/www/drupal-6.13/update.php on line 174.
warning: Invalid argument supplied for foreach() in /var/www/drupal-6.13/update.php on line 338.

The following queries were executed
uc_upsell module
Update #6004

tried uninstall/reinstall, update.php manually selecting 6004, no love. looked into the install arguments for 6004 but couldn't figure, finally had to go back to my hack on the previous dev version.

edit: oh yeah the Buy Now option did not work ofcourse without the variable in the config.

#17

torgosPizza - July 31, 2009 - 03:22

Weird, well you should be able to check the checkbox, and hit Submit, and have it work. The variable gets set if it doesn't exist. I'll try to fix the update issue, though... not sure what would cause it.

#18

Rainman - July 31, 2009 - 03:32

Well that was the first thing I did, of course! wanted to see that option working, but as I said no love.

#19

torgosPizza - July 31, 2009 - 03:46

Okay I think I got it. Open up the uc_upsell.install file and scroll to the bottom. Edit the last update_6004 function so that it looks like this:

function uc_upsell_update_6004() {
  // Adding a new variable to the default config for buy now default

  $ret = array();
  $config = uc_upsell_get_config();
  $config['global']['buy_now'] = FALSE;
  uc_upsell_set_config($config);
 
  $t = get_t();
  $ret[] = array('success' => TRUE, $t('A new configuration for UC Upsell was added.'));

  return $ret;
}

Then you can go to update.php and run the update 6004 again. Let me know if that works.

#20

torgosPizza - July 31, 2009 - 03:49

Really, even that didn't work? Let me look at my sandbox site again.

#21

Rainman - July 31, 2009 - 03:51

whow wait.. think you have messages crossed. haven't tried that install change yet.

#22

torgosPizza - July 31, 2009 - 03:57

FYI I just tried my sandbox, and I got it working. I forgot to include the default during initial module install, though, but I don't think that's related to your problem.

I'll re-commit to Dev soon... let me know if you get it working on your end. If not I'll troubleshoot some more, but I no longer can reproduce the issue on my end.

#23

torgosPizza - July 31, 2009 - 03:59

Yeah I meant to reply to the other one but there is no threading here in the Issue queue. I think once you try changing that code it should work. Failing that, you can unisntall the module and reinstall it, although that will destroy any of your Upsell settings (including any currently associated products).

#24

Rainman - July 31, 2009 - 04:00

OK now you can go back to the sandbox. got rid of the install error but still Buy Now form not showing, it is using Add to Cart. wierd thing is the Buy Now checkbox sticks so seems that the variable is set.

#25

torgosPizza - July 31, 2009 - 04:22

Well it says Add to Cart - i copy-pasted the code that you gave me in your earlier comment - but do the Attributes show? They shouldn't. They don't on my sandbox.

Just FYI this is taken from uc_product.module's function ..

<?php
$form
['submit'] = array(
   
'#type' => 'submit',
   
'#value' =>  variable_get('uc_teaser_add_to_cart_text', t('Add to cart')), // Configure this to say "Buy it now" if you want.
   
'#id' => 'edit-submit-'. $node->nid,
   
'#attributes' => array(
     
'class' => 'list-add-to-cart',
    ),
  );
?>

#26

Rainman - July 31, 2009 - 04:25

Yeah I meant The Add to Cart form with the attributes as opposed to Buy Now form without.

#27

Rainman - August 1, 2009 - 04:37

I just got time to install the latest Dev. everything working, looks real nice and clean now, good work!:)

For anyone following this thread we ended up taking some troubleshooting offline as not to make this a chatboard and also my site was not public yet.. it is now, happily using this module! RainmanWeather Store, select any product to see it in action in all it's glory..

I still removed the "List Price" portion as I just wasn't happy with the way it looked and no amount of CSS tweaking was gonna fix it (I do have it displaying within the individual product pages).

removed portion from uc_upsell.module:

  //dsm($enabled);
  if ($enabled['list_price'] == TRUE) {
    $context = array(
      'location' => 'product-upsell',
      'class' => array(
        'product',
        'list',
      ),
      'subject' => array(
        'node' => $node,
        'field' => 'list_price',
      ),
    );

    $product['list_price'] = array(
      '#value' => uc_price($node->list_price, $context),
      '#access' => $enabled['list_price'],
      '#weight' => $weight['list_price'],
    );
  }

#28

torgosPizza - August 1, 2009 - 06:53

Remember that you don't have to hack the module to do this. You can copy the theme function from the module, and make it a theme override function in your template.php file. So instead of theme_pane_upsell or whatever it is, it would be THEMENAME_pane_upsell (i.e., zen_pane_upsell()) and then your theme function overrides the module's theme function. That way, when you upgrade to a new version of the Upsell module, your changes don't get blown away. :)

#29

System Message - August 15, 2009 - 07:00
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.