Answer the question
In order to leave comments, you need to log in
How to add amount to text option in Opencart?
Good afternoon! I ask for help because the situation is not very clear.
In Opencart, it is possible to add a text option "input type=text" to the product, in which the user can enter arbitrary text. I wanted to add that the price is multiplied by n when using this option, on the product page all good prices are recalculated (using js), but not in the cart, I sort of understood that this procedure should be carried out in the system/library/cart.php file , moved it to a separate "else if" for the text option:
} elseif ($option_query->row['type'] == 'text') {
$option_data[] = array(
'product_option_id' => $product_option_id,
'product_option_value_id' => '',
'option_id' => $option_query->row['option_id'],
'option_value_id' => '',
'name' => $option_query->row['name'],
'option_value' => $option_value,
'type' => $option_query->row['type'],
'quantity' => '1',
'subtract' => '0',
'price' => '2', // (на что умножаем)
'price_prefix' => '*', // (у нас умножение)
'points' => '0',
'points_prefix' => '+',
'weight' => '0',
'weight_prefix' => '+'
);
}
Answer the question
In order to leave comments, you need to log in
I believe that before this code you need to prescribe logic. For example, this code is written for the radio, select, image options:
if ($option_value_query->num_rows) {
if ($option_value_query->row['price_prefix'] == '+') {
$option_price += $option_value_query->row['price'];
} elseif ($option_value_query->row['price_prefix'] == '-') {
$option_price -= $option_value_query->row['price'];
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question