diff --git a/classes/PaymentModule.php b/classes/PaymentModule.php
index 69520408e..a78796d41 100644
--- a/classes/PaymentModule.php
+++ b/classes/PaymentModule.php
@@ -369,7 +369,8 @@ abstract class PaymentModuleCore extends Module
$customization_text .= sprintf(Tools::displayError('%d image(s)'), count($customization['datas'][Product::CUSTOMIZE_FILE])).'
';
$customization_text .= '---
';
}
- $customization_text = rtrim($customization_text, '---
');
+
+ $customization_text = Tools::rtrimString($customization_text, '---
');
$customization_quantity = (int)$product['customization_quantity'];
$products_list .=
diff --git a/classes/Tools.php b/classes/Tools.php
index 6e6ac3151..a3a2df9ac 100644
--- a/classes/Tools.php
+++ b/classes/Tools.php
@@ -2739,6 +2739,20 @@ exit;
}
return $fileAttachment;
}
+
+ /**
+ * Delete a substring from another one starting from the right
+ * @param string $str
+ * @param string $str_search
+ * @return string
+ */
+ public static function rtrimString($str, $str_search)
+ {
+ $length_str = strlen($str_search);
+ if (strlen($str) >= $length_str && substr($str, -$length_str) == $str_search)
+ $str = substr($str, 0, -$length_str);
+ return $str;
+ }
}
/**
@@ -2765,4 +2779,4 @@ function cmpPriceDesc($a, $b)
elseif ((float)$a['price_tmp'] > (float)$b['price_tmp'])
return -1;
return 0;
-}
+}
\ No newline at end of file
diff --git a/modules/mailalerts/mailalerts.php b/modules/mailalerts/mailalerts.php
index 8dddab040..93f6011d3 100644
--- a/modules/mailalerts/mailalerts.php
+++ b/modules/mailalerts/mailalerts.php
@@ -318,7 +318,7 @@ class MailAlerts extends Module
$customization_text .= '---
';
}
- $customization_text = rtrim($customization_text, '---
');
+ $customization_text = Tools::rtrimString($customization_text, '---
');
}
$items_table .=