Hi,

I don't know about PHP but I'd like to have a custom block which shows product price & add to cart in sidebar.
Thus I copied following from node.tpl.php and it didn't work out.

Price: print uc_currency_format($node->sell_price);
print uc_currency_format($node->sell_price);

Can someone help me on this?

CommentFileSizeAuthor
#2 Screenshot-1.png96.15 KBend user
#2 Screenshot-1.png96.15 KBend user

Comments

end user’s picture

I think you could this with views/views templates and templates with Nifty Product http://www.ubercart.org/forum/development/3868/nifty_products_tutorial_p...

The way I would go about if you don't know how to program (could be much easier way) is to create a view and set it to a block. Then use it to display the current nodes price and buy it now button or attributes form. For arguments you would use node id and then filter using Note type =product. Then modify the look of it using views templates. You can get some info here http://www.maybeor.com/blog/drupal-views-theming-rows-tables

Then in the node template remove all product pricing info since it'll be displayed in a block.

end user’s picture

StatusFileSize
new96.15 KB
new96.15 KB

Ok here's what you can do. This is just a basic view in a block form. This site is not live but you can see what I meant http://www.nuttyzone.com/shop/nutrients/general-hydroponics/gh-flora-bloom Then use the Nifty Product tutorial to remove the price/forms from the main body.

I've attached a screen shot also and below is the view export

$view = new view;
$view->name = 'price_block';
$view->description = '';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('fields', array(
  'sell_price' => array(
    'label' => 'Sell price',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'set_precision' => 0,
    'precision' => '0',
    'decimal' => '.',
    'separator' => ',',
    'prefix' => '',
    'suffix' => '',
    'format' => 'uc_price',
    'revision' => 'themed',
    'exclude' => 0,
    'id' => 'sell_price',
    'table' => 'uc_products',
    'field' => 'sell_price',
    'relationship' => 'none',
  ),
  'addtocartlink' => array(
    'label' => '',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'exclude' => 0,
    'id' => 'addtocartlink',
    'table' => 'uc_products',
    'field' => 'addtocartlink',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('arguments', array(
  'nid' => array(
    'default_action' => 'default',
    'style_plugin' => 'default_summary',
    'style_options' => array(),
    'wildcard' => 'all',
    'wildcard_substitution' => 'All',
    'title' => '',
    'breadcrumb' => '',
    'default_argument_type' => 'node',
    'default_argument' => '',
    'validate_type' => 'none',
    'validate_fail' => 'not found',
    'break_phrase' => 0,
    'not' => 0,
    'id' => 'nid',
    'table' => 'node',
    'field' => 'nid',
    'validate_user_argument_type' => 'uid',
    'validate_user_roles' => array(
      '2' => 0,
    ),
    'relationship' => 'none',
    'default_options_div_prefix' => '',
    'default_argument_fixed' => '',
    'default_argument_user' => 0,
    'default_argument_php' => '',
    'validate_argument_node_type' => array(
      'product' => 0,
      'product_kit' => 0,
      'forum' => 0,
      'page' => 0,
      'story' => 0,
    ),
    'validate_argument_node_access' => 0,
    'validate_argument_nid_type' => 'nid',
    'validate_argument_vocabulary' => array(
      '1' => 0,
      '2' => 0,
    ),
    'validate_argument_type' => 'tid',
    'validate_argument_transform' => 0,
    'validate_user_restrict_roles' => 0,
    'validate_argument_php' => '',
  ),
));
$handler->override_option('filters', array(
  'type' => array(
    'operator' => 'in',
    'value' => array(
      'product' => 'product',
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'type',
    'table' => 'node',
    'field' => 'type',
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
$handler = $view->new_display('block', 'Block', 'block_1');
$handler->override_option('block_description', '');
$handler->override_option('block_caching', -1);
longwave’s picture

Status: Active » Fixed

#1 answers this; use Views and add whatever fields you need.

tr’s picture

There's also a sandbox project that does this for Drupal 7 Ubercart: http://drupal.org/node/1149550
The sandbox owner says he intends to backport it.

Status: Fixed » Closed (fixed)

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