Skip to main content
Too many spaces, few capitals
Source Link
Countzero
  • 3k
  • 17
  • 23

I tested the above answer, it useful but not changed the Order Total Amount.
After do some research and I finally get all done.
For those people who don't want to use rules and hope to alter the price directly. Here is my solution:

//alter Alter the price in list and single product page
function my_module_commerce_product_calculate_sell_price_line_item_alter($line_item){
    
    $price = 100; // 1 dollar
    $line_item->commerce_unit_price[LANGUAGE_NONE]['0']['amount']=$price;

}

//alter Alter the price in cart & order
function my_module_commerce_cart_line_item_refresh($line_item, $order_wrapper){

    $price = 100; //1 dollar
    $line_item->commerce_unit_price[LANGUAGE_NONE]['0']['amount']=$price;
    $line_item->commerce_unit_price[LANGUAGE_NONE]['0']['data']['components']['0']    ['price']['amount']=$price;>commerce_unit_price[LANGUAGE_NONE]['0']['data']['components']['0']['price']['amount']=$price; // alter the base_price component

}

I tested the above answer, it useful but not changed the Order Total Amount.
After do some research and I finally get all done.
For those people who don't want to use rules and hope to alter the price directly. Here is my solution:

//alter the price in list and single product page
function my_module_commerce_product_calculate_sell_price_line_item_alter($line_item){
    
    $price = 100; //1 dollar
    $line_item->commerce_unit_price[LANGUAGE_NONE]['0']['amount']=$price;

}

//alter the price in cart & order
function my_module_commerce_cart_line_item_refresh($line_item, $order_wrapper){

    $price = 100; //1 dollar
    $line_item->commerce_unit_price[LANGUAGE_NONE]['0']['amount']=$price;
    $line_item->commerce_unit_price[LANGUAGE_NONE]['0']['data']['components']['0']    ['price']['amount']=$price; //alter the base_price component

}

I tested the above answer, it useful but not changed the Order Total Amount.
After do some research and I finally get all done.
For those people who don't want to use rules and hope to alter the price directly. Here is my solution:

// Alter the price in list and single product page
function my_module_commerce_product_calculate_sell_price_line_item_alter($line_item){
    
    $price = 100; // 1 dollar
    $line_item->commerce_unit_price[LANGUAGE_NONE]['0']['amount']=$price;

}

// Alter the price in cart & order
function my_module_commerce_cart_line_item_refresh($line_item, $order_wrapper){

    $price = 100; //1 dollar
    $line_item->commerce_unit_price[LANGUAGE_NONE]['0']['amount']=$price;
    $line_item->commerce_unit_price[LANGUAGE_NONE]['0']['data']['components']['0']['price']['amount']=$price; // alter the base_price component

}
Source Link
Tim Yao
  • 455
  • 4
  • 10

I tested the above answer, it useful but not changed the Order Total Amount.
After do some research and I finally get all done.
For those people who don't want to use rules and hope to alter the price directly. Here is my solution:

//alter the price in list and single product page
function my_module_commerce_product_calculate_sell_price_line_item_alter($line_item){
    
    $price = 100; //1 dollar
    $line_item->commerce_unit_price[LANGUAGE_NONE]['0']['amount']=$price;

}

//alter the price in cart & order
function my_module_commerce_cart_line_item_refresh($line_item, $order_wrapper){

    $price = 100; //1 dollar
    $line_item->commerce_unit_price[LANGUAGE_NONE]['0']['amount']=$price;
    $line_item->commerce_unit_price[LANGUAGE_NONE]['0']['data']['components']['0']    ['price']['amount']=$price; //alter the base_price component

}