diff --git a/assets/js/src/newsletter_editor/blocks/products.js b/assets/js/src/newsletter_editor/blocks/products.js index 869fb0ac94..96b24abf80 100644 --- a/assets/js/src/newsletter_editor/blocks/products.js +++ b/assets/js/src/newsletter_editor/blocks/products.js @@ -44,7 +44,7 @@ Module.ProductsBlockModel = base.BlockModel.extend({ terms: [], // List of category and tag objects search: '', // Search keyword term inclusionType: 'include', // 'include'|'exclude' - displayType: 'titleOnly', // 'short'|'full'|'titleOnly' + displayType: 'excerpt', // 'excerpt'|'full'|'titleOnly' titleFormat: 'h1', // 'h1'|'h2'|'h3' titleAlignment: 'left', // 'left'|'center'|'right' titleIsLink: false, // false|true diff --git a/lib/Newsletter/Editor/PostContentManager.php b/lib/Newsletter/Editor/PostContentManager.php index abdc397fd9..ec5f0681fd 100644 --- a/lib/Newsletter/Editor/PostContentManager.php +++ b/lib/Newsletter/Editor/PostContentManager.php @@ -1,6 +1,7 @@ max_excerpt_length = $wp->applyFilters('mailpoet_newsletter_post_excerpt_length', $this->max_excerpt_length); + $this->woocommerce_helper = new WooCommerceHelper(); } function getContent($post, $displayType) { + $product = null; + if ($this->woocommerce_helper->isWooCommerceActive() && $post->post_type === 'product') { + $product = wc_get_product($post->ID); + } if ($displayType === 'titleOnly') { return ''; } elseif ($displayType === 'excerpt') { - // get excerpt + if ($product) { + return $product->get_short_description(); + } if (!empty($post->post_excerpt)) { return self::stripShortCodes($post->post_excerpt); } else { return $this->generateExcerpt(self::stripShortCodes($post->post_content)); } } else { + if ($product) { + return $product->get_description(); + } return self::stripShortCodes($post->post_content); } } diff --git a/tasks/phpstan/bootstrap.php b/tasks/phpstan/bootstrap.php index 29863ca024..8256eb9c73 100644 --- a/tasks/phpstan/bootstrap.php +++ b/tasks/phpstan/bootstrap.php @@ -24,3 +24,6 @@ function wc_price(float $price, array $args = []): string { return ''; } +function wc_get_product($the_product = false, $deprecated = array()) { + return null; +} diff --git a/views/newsletter/editor.html b/views/newsletter/editor.html index a9aa00b158..e522c84511 100644 --- a/views/newsletter/editor.html +++ b/views/newsletter/editor.html @@ -1337,7 +1337,7 @@ contentType: 'product', postStatus: 'publish', // 'draft'|'pending'|'publish' inclusionType: 'include', // 'include'|'exclude' - displayType: 'titleOnly', // 'short'|'full'|'titleOnly' + displayType: 'excerpt', // 'excerpt'|'full'|'titleOnly' titleFormat: 'h1', // 'h1'|'h2'|'h3' titleAlignment: 'left', // 'left'|'center'|'right' titleIsLink: false, // false|true diff --git a/views/newsletter/templates/blocks/products/settingsDisplayOptions.hbs b/views/newsletter/templates/blocks/products/settingsDisplayOptions.hbs index 537d286636..004c274aa6 100644 --- a/views/newsletter/templates/blocks/products/settingsDisplayOptions.hbs +++ b/views/newsletter/templates/blocks/products/settingsDisplayOptions.hbs @@ -7,7 +7,7 @@