Skip to content

Catch edge case where the line item isn't an object#307

Merged
brtkwr merged 1 commit intotwo-inc:mainfrom
jameshobden:main
Jun 30, 2025
Merged

Catch edge case where the line item isn't an object#307
brtkwr merged 1 commit intotwo-inc:mainfrom
jameshobden:main

Conversation

@jameshobden
Copy link
Copy Markdown
Contributor

No description provided.

@jameshobden jameshobden requested a review from a team June 30, 2025 13:14
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Bug: Featured Image URL Returns Boolean

The image_url in the product array can now be false instead of an empty string. This occurs when get_the_post_thumbnail_url() returns false for products without a featured image. Previously, a ternary operator ensured false values were converted to an empty string. The updated logic passes false directly, changing the data type from string to boolean and potentially causing issues for consumers expecting a string.

class/WC_Twoinc_Helper.php#L276-L295

$description = substr($product_simple->get_description(), 0, 255);
$image_url = $product_simple->get_id() ? get_the_post_thumbnail_url($product_simple->get_id()) : '';
$product_page_url = $product_simple->get_permalink();
$sku = $product_simple->get_sku();
$categories = wp_get_post_terms($product_simple->get_id(), 'product_cat');
}
$product = [
'name' => $name,
'description' => $description,
'gross_amount' => strval(WC_Twoinc_Helper::round_amt($line_item['line_total'] + $line_item['line_tax'])),
'net_amount' => strval(WC_Twoinc_Helper::round_amt($line_item['line_total'])),
'discount_amount' => strval(WC_Twoinc_Helper::round_amt($line_item['line_subtotal'] - $line_item['line_total'])),
'tax_amount' => strval(WC_Twoinc_Helper::round_amt($line_item['line_tax'])),
'tax_class_name' => $tax_rate['name'],
'tax_rate' => strval(WC_Twoinc_Helper::round_rate($tax_rate['rate'])),
'unit_price' => strval($order->get_item_subtotal($line_item, false, true)),
'quantity' => $line_item['quantity'],
'quantity_unit' => 'item',
'image_url' => $image_url,

Fix in Cursor


Was this report helpful? Give feedback by reacting with 👍 or 👎

@jameshobden
Copy link
Copy Markdown
Contributor Author

I think because I'm not a member of the two-inc org the checks fail

@brtkwr brtkwr merged commit 0a2ffea into two-inc:main Jun 30, 2025
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants