Right now, the fields displayed mirror exactly the fields displayed on a product page. This isn't good, since List Price is something we may only care about on the product detail page itself, and not on the Upsell block.

1) Need to add a new setting someplace that grabs all of the Ubercart and CCK-provided fields, to allow the user to switch on/off fields that get displayed.

2) Need to keep in mind the addition of multiple Upsell blocks in 2.x.

3) Need to also make it so that the default Ubercart fields are enabled by default, but additional CCK fields are not. (Distinguish core product fields from CCK fields.)

Comments

torgospizza’s picture

Title: Abstract field display settings - don't use the global UC product field settings » Field display settings should be independent of how Ubercart displays product fields
yaworsk’s picture

subscribing

Rainman’s picture

Excellent!

I have been manually hacking list price out of the module since the beginning.. not a nice way to do things and a pain to have to do everytime the module is updated.

ahimsauzi’s picture

Good point!

Cab anyone recommend a function to override the default field display?

torgospizza’s picture

Sorry, this has fallen off my radar for a bit. If anyone wants to hack the module to do what needs to be done, I'd be willing to review and commit. If not, give me some more time and then I can take another swing at it.

yaworsk’s picture

Hi all,
speaking only to the upsell portion of this issue, yesterday I created a function in my site's template.php file to override the output the upsell module. I was able to separate the return of the list price and add a div to it (I needed it separate b/c i only wanted prices shown to logged in users).

I play on separating the buy it now info as well. If it would help, I can paste my template function (i'm at work now and don't have access to it). Please let me know if it would help but be forewarned, I'm no expert and there may have been a better way to do it.

pete

torgospizza’s picture

Yeah a template function isn't the best solution, but it might help others in the meantime. Keep in mind that once I add the ability to do this on a per-field basis, that template function may break.

yaworsk’s picture

Hey targos,
I figured it may not be the best -- I'm still pretty new to themeing. Thanks for the heads up about the break. Out of my own inexperience, I'm assuming when you say not the best solution, the preferred alternative would be to alter ubercart's .module file? Is there a better way than the template.php besides hacking uc's .module? Forgive me if this is a stupid question...

pete

torgospizza’s picture

No, hacking - or modifying - the module is the way to go, but it'd be Upsell (which is my module) and then once you have a modification that works for everyone, submitting that as a patch. It's something I hope to have ready soon, in the near future. I'm just so busy right now it has to wait.

yaworsk’s picture

hi targos,
i'm not exactly sure on how to create a patch. would it help if i uploaded the code (in a zip file) which i hacked? also, i noticed in the module file, under sell_price, you call the display price and not actually the sell price itself... any reason why?

also, (I don't mean to hijack this thread so let me know if i should start a new one) but i was trying to hack the module to ultimately allow for sale prices to be shown with strikethrough (i.e. was [list_price], now [sell_price]) but I ran into some road blocks... have you ever thought about this functionality as well? i know it has been discussed with uc and there is a patch for it but i haven't tested that either, i realized it's a little more work than i originally envisioned.

thanks,
pete

Rainman’s picture

This may indeed be drifting from the issue, but wanted to share my simple solution to the strikethrough for List Price

Simply add the following to your theme CSS:


.uc-price-list {
text-decoration: line-through;
}

yaworsk’s picture

yup that is a solution but that means you always have to have a list price - in the event that the list price and sell price don't differ, you'd have the same thing....

sorry for getting off track.

torgospizza’s picture

@yaworsk: If you can post a module thats fine but diffs are better :) You can see how to do it here: http://drupal.org/patch/create

yaworsk’s picture

hi torgos,
thanks, i'll take a look and try to get the patch up in the next fews days.

pete

ahimsauzi’s picture

Hi Torgos,

I simply removed the following code from line 241 to 307. Felt like a major hack but it got rid of the add to cart and the price list fields.

Please let me know if that will break anything.

Thanks

Uzi

// Only show an "add to cart" link if there is a value for Sell Price
// TODO: Make destination configurable
$weight = variable_get('uc_product_field_weight', array(
'image' => -2,
'display_price' => -1,
'model' => 0,
'list_price' => 2,
'cost' => 3,
'sell_price' => 4,
'weight' => 5,
'dimensions' => 6,
'add_to_cart' => 10,
));

$product = array(
'#node' => $node,
);

// Only display the list price if the field is configured in Product Settings.
$enabled = variable_get('uc_product_field_enabled', array(
'image' => 1,
'display_price' => 1,
'model' => 1,
'list_price' => 0,
'cost' => 0,
'sell_price' => 1,
'weight' => 0,
'dimensions' => 0,
'add_to_cart' => 1,
));

$context = array(
'revision' => 'themed',
'type' => 'product',
'class' => array('product'),
'subject' => array('node' => $node),
);

if ($enabled['list_price']) {
$context['class'][1] = 'list';
$context['field'] = 'list_price';
$product['list_price'] = array(
'#value' => uc_price($node->list_price, $context),
'#access' => $enabled['list_price'],
'#weight' => $weight['list_price'],
);
}

$context['class'][1] = 'sell';
$context['field'] = 'sell_price';
$product['sell_price'] = array(
'#value' => uc_price($node->sell_price, $context),
'#access' => $enabled['display_price'],
'#weight' => $weight['display_price'],
);

// Show a Buy Now form if we are configured to do so.
if ($config['global']['buy_now'] == TRUE) {
$product['add_to_cart'] = array('#value' => drupal_get_form('uc_catalog_buy_it_now_form_'. $node->nid, $node));
}
else {
$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'],
);
}

sreese’s picture

I would also like to be able to include some of my custom (CCK) fields that we've added to the Product content type. Can anyone give me an example of how to do this? This thread seemed like an appropriate place to ask since it appears the original post describes the features I am needing. For now I would settle for someone giving me a clue on how to access/display my additional fields. Thanks in advance.

orchard’s picture

I have the same issue as sreese. I would also like to be able to include some of my custom (CCK) fields that we've added to the Product content type. I have a listing of very similar products and would like to show CCK fields on the /cart page, and during the checkout pages so the user can differentiate them.

Thanks

torgospizza’s picture

The module isn't able to support CCK fields out of the box, but if you were to override the theme function (I forget what it's called offhand) you should be able to add things that way, if you're comfortable writing php that calls CCK functions. I'm not sure how I would best handle this going forward, since you'd be basically invoking node display hooks. I'm wondering if Upsell should just use Views, which would free up a lot of this.

Essentially you could use UC Views to build the same kind of block, but the relationships would have to be added for a parent node->related nodes, and with the db table structure for Upsell the way it currently is, it's not possible yet. I'll add Views integration as my #1 goal for the 2.x version of the module, unless it gets superceded by UC Views.

bkosborne’s picture

Integrating this with views with be so ideal. Wouldn't have any of these issues with block formatting - could just generate a block from a view instead. Maybe once I get get done with my module development book... hah

n9f9rt1t1’s picture

What about the module Power tools?
Although I am having some difficulties to make complete good use of it. It is suppose to do exactly what you expect from.
I am myself also tempted in finding a hacking solution to the problem

torgospizza’s picture

#19: Actually I was thinking about doing this entirely, making the block be the result of a View (which would be provided by the module as a Default that could be overridden) or a View that you attach to a page as as block, etc. But if you're having issues with block formatting, you can override the theme functions that are provided in the module itself to theme the block (and its contents) however you want.

#20: We are using Power Tools, but that's an unrelated module. I don't know what your issue is, as you didn't say.