{"action":"closed","issue":{"url":"https://api.github.com/repos/woothemes/woocommerce/issues/7395","labels_url":"https://api.github.com/repos/woothemes/woocommerce/issues/7395/labels{/name}","comments_url":"https://api.github.com/repos/woothemes/woocommerce/issues/7395/comments","events_url":"https://api.github.com/repos/woothemes/woocommerce/issues/7395/events","html_url":"https://github.com/woothemes/woocommerce/issues/7395","id":57490964,"number":7395,"title":"Woocommerce 2.3 Breaks Coupons with Ampersands and Special Characters","user":{"login":"treyrich2001","id":1641028,"avatar_url":"https://avatars.githubusercontent.com/u/1641028?v=3","gravatar_id":"","url":"https://api.github.com/users/treyrich2001","html_url":"https://github.com/treyrich2001","followers_url":"https://api.github.com/users/treyrich2001/followers","following_url":"https://api.github.com/users/treyrich2001/following{/other_user}","gists_url":"https://api.github.com/users/treyrich2001/gists{/gist_id}","starred_url":"https://api.github.com/users/treyrich2001/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/treyrich2001/subscriptions","organizations_url":"https://api.github.com/users/treyrich2001/orgs","repos_url":"https://api.github.com/users/treyrich2001/repos","events_url":"https://api.github.com/users/treyrich2001/events{/privacy}","received_events_url":"https://api.github.com/users/treyrich2001/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-02-12T17:21:31Z","updated_at":"2015-02-12T22:50:30Z","closed_at":"2015-02-12T22:50:30Z","body":"We had a couple coupons in the system that had ampersands in them, once we updated to Woocommerce 2.3 the coupons began reporting that they didn't exist.\r\n\r\nAfter digging through the code I discovered this function in class-wc-coupon.php\r\n```php\r\n/**\r\n * Gets an coupon from the database.\r\n *\r\n * @param string $code\r\n * @return bool\r\n */\r\nprivate function get_coupon( $code ) {\r\n\t$this->code  = apply_filters( 'woocommerce_coupon_code', $code );\r\n\r\n\t// Coupon data lets developers create coupons through code\r\n\tif ( $coupon = apply_filters( 'woocommerce_get_shop_coupon_data', false, $code ) ) {\r\n\t\t$this->populate( $coupon );\r\n\t\treturn true;\r\n\t} elseif ( ( $this->id = $this->get_coupon_id_from_code( $code ) ) && $this->code === get_the_title( $this->id ) ) {\r\n\t\t$this->populate();\r\n\t\treturn true;\r\n\t}\r\n\r\n\treturn false;\r\n}\r\n```\r\n\r\nThe breaking line in question is `} elseif ( ( $this->id = $this->get_coupon_id_from_code( $code ) ) && $this->code === get_the_title( $this->id ) ) {` the issue being that the function `get_the_title` escapes characters like ampersand for HTML output.\r\n\r\nI implemented a temporary work around by changing the call to `get_the_title` to `html_entity_decode( get_the_title( $this->id ) )`. But a permanent fix should be implemented, even if that fix is preventing people from creating coupons with special characters in them, people shouldn't be able to create coupons in the admin area that then don't work for customers. We potentially lost money from this issue because we had sent out an email with the coupon in it without realizing it had broken until customers started complaining."}}