diff --git a/Helper/ProductHelper.php b/Helper/ProductHelper.php index e53df27e..6cac9043 100644 --- a/Helper/ProductHelper.php +++ b/Helper/ProductHelper.php @@ -80,7 +80,7 @@ public static function getDiscountAmount($product) */ public static function extractValueFromTitle($title) { - return (float)preg_replace('/[^0-9,]/', '', $title); + return (float)preg_replace('/[^0-9,]/', '', ProductHelper::getStringBetween($title, '(', ')')); } /** @@ -104,6 +104,22 @@ public static function convertDecimalMoney($amount) return $amount; } + /** + * @param string $str + * @param string $starting_word + * @param string $ending_word + * @return string + */ + public static function getStringBetween($str, $first_string, $second_string) + { + $arr = explode($first_string, $str); + if (isset($arr[1])) { + $arr = explode($second_string, $arr[1]); + return $arr[0]; + } + return ''; + } + /** * @param int $number * @return float