Hello,
Try to replace the line:
add_action('woocommerce_before_calculate_totals', array($this, 'add_option_price_on_checkout'), 99);
with:
add_filter('woocommerce_add_cart_item', array($this, 'add_option_price_on_checkout'), 99);
add_filter('woocommerce_get_cart_item_from_session', array($this, 'add_option_price_on_checkout'), 99);
And replace the function add_option_price_on_checkout with this:
public function add_option_price_on_checkout($citem){
$key = $citem['key'];
if (!isset($citem['pofw_option']) || isset($this->_poPriceAdded[$key]))
return $citem;
$selectedValues = $citem['pofw_option'];
$productId = $citem["product_id"];
$_product = wc_get_product($productId);
$orgPrice = $citem["data"]->get_price();//$_product->get_price();
$optionPrice = 0;
foreach ($this->getProductOptions($productId) as $oId => $option){
if (!isset($selectedValues[$oId])){
continue;
}
$selectedValue = $selectedValues[$oId];
if ($option['type'] == 'drop_down' || $option['type'] == 'radio'){
if (is_array($selectedValue)){
continue;
}
$vId = (int) $selectedValue;
if (isset($option['values'][$vId])){
$optionPrice += (float) $option['values'][$vId]['price'];
}
} elseif ($option['type'] == 'multiple' || $option['type'] == 'checkbox'){
foreach ((array) $selectedValue as $vId){
if (isset($option['values'][$vId])){
$optionPrice += (float) $option['values'][$vId]['price'];
}
}
} elseif ($option['type'] == 'field' || $option['type'] == 'area' || $option['type'] == 'file'){
if (is_array($selectedValue)){
continue;
}
$optionPrice += (float) $option['price'];
}
}
$citem["data"]->set_price($orgPrice + $optionPrice);
$this->_poPriceAdded[$key] = 1;
return $citem;
}
in the file:
wp-content/plugins/product-options-for-woocommerce/Model/Observer.php
Stanislav