By hjjpoort on
Ubercart does not reduce inventory if you do add to cart
I'm using Drupal 6 with Ubercart. I also have among which the modules ajax cart and
Multi stock.
What I fail is that the stock will be adjusted as you add it to the cart, the inventory is only updated when you do checkout.
It would be nicer to have a picture shows green when it is in stock, and
red out of stock.
The following fields are:
Title
Image
selling
Stock
Buy it Now button
I use a view to including the following:
$view = new view;
$view->name = 'uc_products';
$view->description = 'List of products.';
$view->tag = 'Ubercart';
$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(
'title' => array(
'label' => 'Title',
'link_to_node' => 1,
'exclude' => 0,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'relationship' => 'none',
),
'field_image_cache_fid' => 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,
'link_to_node' => 1,
'label_type' => 'none',
'format' => 'product_list_linked',
'multiple' => array(
'group' => 1,
'multiple_number' => '1',
'multiple_from' => '0',
'multiple_reversed' => 0,
),
'exclude' => 0,
'id' => 'field_image_cache_fid',
'table' => 'node_data_field_image_cache',
'field' => 'field_image_cache_fid',
'relationship' => 'none',
'override' => array(
'button' => 'Override',
),
),
'sell_price' => array(
'label' => 'Sell price',
'exclude' => 0,
'id' => 'sell_price',
'table' => 'uc_products',
'field' => 'sell_price',
'relationship' => 'none',
),
'threshold' => array(
'label' => 'Stock level',
'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' => 'out of stock',
'hide_empty' => 0,
'empty_zero' => 1,
'set_precision' => FALSE,
'precision' => 0,
'decimal' => '.',
'separator' => ',',
'prefix' => '',
'suffix' => '',
'exclude' => 0,
'id' => 'threshold',
'table' => 'uc_product_stock',
'field' => 'threshold',
'relationship' => 'none',
),
'buyitnowbutton' => 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' => 'buyitnowbutton',
'table' => 'uc_products',
'field' => 'buyitnowbutton',
'relationship' => 'none',
),
));
$handler->override_option('filters', array(
'status' => array(
'operator' => '=',
'value' => 1,
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'status',
'table' => 'node',
'field' => 'status',
'relationship' => 'none',
),
'is_product' => array(
'operator' => '=',
'value' => 1,
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'is_product',
'table' => 'uc_products',
'field' => 'is_product',
'relationship' => 'none',
),
'language' => array(
'operator' => 'in',
'value' => array(
'***CURRENT_LANGUAGE***' => '***CURRENT_LANGUAGE***',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'language',
'table' => 'node',
'field' => 'language',
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
'role' => array(),
'perm' => '',
));
$handler->override_option('cache', array(
'type' => 'none',
));
$handler->override_option('title', 'Products');
$handler->override_option('use_ajax', TRUE);
$handler->override_option('use_pager', '1');
$handler->override_option('style_plugin', 'grid');
$handler->override_option('style_options', array(
'grouping' => '',
'columns' => '2',
'alignment' => 'horizontal',
'fill_single_line' => 1,
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'products');
$handler->override_option('menu', array(
'type' => 'none',
'title' => '',
'description' => '',
'weight' => 0,
'name' => 'navigation',
));
$handler->override_option('tab_options', array(
'type' => 'none',
'title' => '',
'description' => '',
'weight' => 0,
'name' => 'navigation',
));