Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only pad order increment id with zeros if it is numeric #34

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion app/code/community/Wirecard/CheckoutPage/Model/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,13 @@ public function getOrder() {
* @return string
*/
protected function getOrderReference() {
return sprintf( '%010d', $this->getOrder()->getRealOrderId() );
$orderIncrementId = $this->getOrder()->getRealOrderId();
if ( ! is_numeric( $orderIncrementId ))
{
return $orderIncrementId;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please use substring with length of 10 (preferably from the end of the string) so that we don't exceed the max length of this parameter.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, this can be done. But be aware that in magento the increment id is not limited to a length of 10 but rather could grow up to 50 chars in length (see eav_entity_store table).

Also, in the current implementation sprintf( '%010d', $this->getOrder()->getRealOrderId() ); the length can already exceed 10. That statement will insert 0's until the string is exactly 10 chars in length. If it is longer than 10 chars the string won't be modified, though, resulting in problems already now.

}

return sprintf( '%010d', $orderIncrementId );
}

/**
Expand Down