Magento 2 M2E Pro Shipping Policy Bug Unknown Modifier H
Please note that this post is over a year old and may contain outdated information.
When attempting to edit or create an eBay Shipping Policy in M2E Pro for Magento 2, you may come across an error like this:
This happens because the method modifyNonUniqueShippingServicesTitles doesn't properly escape a string before running it through a preg_replace, causing the regular expression to end early. That method is located in this file:
The part of the method that is failing is at this line:
To resolve it, add this line of code prior to that code:
It should now look like this:
I have submitted this bug to M2E Pro in hopes they'll fix it in the next update.
{"error": "Warning: preg_replace(): Unknown modifier 'H' in \/app\/code\/Ess\/M2ePro\/Block\/Adminhtml\/Ebay\/Template\/Shipping\/Edit\/Form\/Data.php on line 1733"}
This happens because the method modifyNonUniqueShippingServicesTitles doesn't properly escape a string before running it through a preg_replace, causing the regular expression to end early. That method is located in this file:
/app/code/Ess/M2ePro/Block/Adminhtml/Ebay/Template/Shipping/Edit/Form/Data.php
The part of the method that is failing is at this line:
$uniqPart = preg_replace('/\w*'.str_replace(' ', '', $title).'/i', '', $ebayId);
To resolve it, add this line of code prior to that code:
// Escapes any '/' in title so preg_replace doesn't fail
$title = str_replace('/', '\/', $title);
It should now look like this:
// Escapes any '/' in title so preg_replace doesn't fail
$title = str_replace('/', '\/', $title);
$uniqPart = preg_replace('/\w*'.str_replace(' ', '', $title).'/i', '', $ebayId);
I have submitted this bug to M2E Pro in hopes they'll fix it in the next update.