I'm building an ecommerce site where some products are price negotiable and want a way to add POA instead of a listing a price when a product is displayed.
I'm kinda surprised at how hard this is to do.. I have a snippet that works for Ubercart 1 in Drupal 5, but it looks like the hooks have changed in Ubercart 3 and I can't find a pricing hook:
<?php
function zen_uc_product_display_price($price) {
$output = '<div class="display_price">';
if ($price!=0) {
$output .= uc_currency_format($price);
} else {
$output .= t('P.O.A');
}
$output .= '</div>';
return $output;
}
function
zen_uc_product_sell_price($price, $teaser) {
if ($teaser) {
$output = '<span class="sell_price">';
if ($price!=0) {
$output .= uc_currency_format($price);
} else {
$output .= t('P.O.A');
}
$output .= '</span>';
}
else {
$output = '<div class="sell_price">';
if ($price!=0) {
$output .= t('Price: !price', array('!price' => uc_currency_format($price)));
} else {
$output .= t('Price: P.O.A');
}
$output .= '</div>';
}
return $output;
}
?>
I've managed to hook the add to cart function and direct it to a webform with the following snippet:
<?php
function fmc_uc_product_add_to_cart( $variables ) {
$sell_price = $variables['form']['node']['#value']->price;
if ($sell_price <= 0) {
return '<form action="http://www.example.com/" method="post"><input type="hidden" name="product" value="' . drupal_get_title() . '" /><input type="submit" class="form-submit" value="' . t('POA') . '" /></form>';
}
else {
return fmc_uc_product_add_to_cart($variables);
}
}
But I'm having no luck with the pricing function, if anyones got a code snippet I can run in my template.php file that'd be the ideal solution, but any ideas / advice is hugely appreciated. Is there a way this can be broken out inside a node--product.tpl.php file maybe?