[support] Views, Ubercart, form_alter based on other Views field

Ron Dorman rwd at simplydigtech.net
Tue Nov 2 22:10:26 UTC 2010


I'm working on a site requirement where products in Ubercart with a 0 
price show a text message instead of an 'add to cart' form.

The product list is being generated by views and presented in table 
layout. Some of the products selected by the view have a price (view is 
using 'sell price'), some do not.

The current code works for the 'form_alter' for non-0 price. The current 
code works for replacing the form with text. *It does not work in 
determining which products (rows) in the table are 0 price.*

I have not been able to nail down whether the issue is the reference to 
the 'price' field in the view record or if it is my comparison value (is 
it already formatted for display at this point).

Any suggestions welcomed an appreciated.

Here is my current code:
> <?php
> // $Id$
>
> /**
> * Implementation of hook_form_alter().
> */
> function clientname_cart_form_alter(&$form, $form_state, $form_id) {
>    //only 'add to cart forms'
>    if(substr($form_id, 0, 28) == 'uc_product_add_to_cart_form_')  {
>      if($node->sell_price == 0) {
>        // if 0.00 price, show 'call for quote' text
>        $form['qty'] = array(
>          '#type'   =>  'markup',
>          '#value' =>  '<div>Call for Quote</div>',
>        );
>        $form['submit'] = array(
>          '#type' =>  'markup',
>          '#value' =>  '',
>        );
>      }
>      else {
>        // if>0.00 price alter the form
>        $form['qty'] = array(
>          '#type'   =>  'textfield',
>          '#default_value' =>  '1',
>          '#description' =>  '',
>          '#size' =>  '1',
>          '#maxlength' =>  4,
>        );
>      }
>    }
> }

Ron D.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20101102/cedc0091/attachment.html 


More information about the support mailing list