【问题标题】:Ubercart cart not removing object in Drupal 7?Ubercart 购物车没有在 Drupal 7 中移除对象?
【发布时间】:2015-01-09 08:49:08
【问题描述】:

我正在使用以下代码添加一个项目:

$some_data = array(
    'attributes' => array( 
        6 => $domainName, 
        1 => $domain->oid,
        2 => 705,
        7 => 706,
        8 => '',
        9 => '', 
        10 => '',
        11 => '',
    ),
);
$some_data = serialize($some_data);
uc_cart_add_item(
    $domainProductNID, 
    1,
    $some_data
);

它使用正确的配置将商品添加到购物车。但是,如果我然后转到 /cart 并单击“删除”,则该项目将保留在那里。我只能通过以下方式删除它:

uc_cart_empty();

知道为什么吗?

更新

删除 $some_data 属性并改为运行:

uc_cart_add_item(
    $domainProductNID, 
    1
);

确实有效...所以它必须与提交的属性有关。

【问题讨论】:

    标签: drupal-7 ubercart


    【解决方案1】:

    这解决了我的问题:

    $domainProductNID    =    27;
    $form_state    =    array(
      'values'    =>    array(
            'nid'    =>    $domainProductNID,
            'qty'    =>    1,
            'attributes'    =>    array(    
                 6    =>    $domainName,
                 1    =>    $domain->oid,
                 2    =>    705,
                 7    =>    706,
                 8    =>    '',  
                 9    =>    '',  
                 10    =>    '',
                 11    =>    '',
            )
      ),
    
    );
    $node    =    node_load($domainProductNID);
    drupal_form_submit("uc_product_add_to_cart_form",    $form_state,    $node);
    

    希望它可以帮助别人......

    【讨论】:

      猜你喜欢
      • 2012-06-29
      • 2018-05-07
      • 2023-03-04
      • 2011-08-12
      • 2011-06-18
      • 2011-03-15
      • 2011-01-24
      • 2013-08-29
      • 1970-01-01
      相关资源
      最近更新 更多