Skip to content

Commit

Permalink
Add rich text description to woo product sync to meta
Browse files Browse the repository at this point in the history
  • Loading branch information
David Evbodaghe committed Feb 11, 2025
1 parent c21e9c9 commit ca0c1a4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
22 changes: 6 additions & 16 deletions includes/fbproduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ class WC_Facebook_Product {
*/
private $fb_description;


/**
* @var array Gallery URLs.
*/
Expand Down Expand Up @@ -801,18 +800,6 @@ public function prepare_product( $retailer_id = null, $type_to_prepare_for = sel
$categories =
WC_Facebookcommerce_Utils::get_product_categories( $id );

// Get brand attribute.
$brand = get_post_meta( $id, Products::ENHANCED_CATALOG_ATTRIBUTES_META_KEY_PREFIX . 'brand', true );
$brand_taxonomy = get_the_term_list( $id, 'product_brand', '', ', ' );

if ( $brand ) {
$brand = WC_Facebookcommerce_Utils::clean_string( $brand );
} elseif ( ! is_wp_error( $brand_taxonomy ) && $brand_taxonomy ) {
$brand = WC_Facebookcommerce_Utils::clean_string( $brand_taxonomy );
} else {
$brand = wp_strip_all_tags( WC_Facebookcommerce_Utils::get_store_name() );
}

$custom_fields = $this->get_facebook_specific_fields();

if ( self::PRODUCT_PREP_TYPE_ITEMS_BATCH === $type_to_prepare_for ) {
Expand All @@ -825,7 +812,7 @@ public function prepare_product( $retailer_id = null, $type_to_prepare_for = sel
'link' => $product_url,
'product_type' => $categories['categories'],
'brand' => Helper::str_truncate( $this->get_fb_brand(), 100 ),
'mpn' => Helper::str_truncate( $this->get_fb_mpn(), 100 ),
'mpn' => Helper::str_truncate( $this->get_fb_mpn(), 100 ),
'retailer_id' => $retailer_id,
'price' => $this->get_fb_price( true ),
'availability' => $this->is_in_stock() ? 'in stock' : 'out of stock',
Expand Down Expand Up @@ -1002,8 +989,11 @@ function ( $key ) {

$matched_attributes = array_filter(
$all_attributes,
function ( $attribute ) use ( $sanitized_keys ) {
return in_array( $attribute['key'], $sanitized_keys );
function( $attribute ) use ( $sanitized_keys ) {
if ( is_array( $attribute ) && isset( $attribute['key'] ) ) {
return in_array( $attribute['key'], $sanitized_keys );
}
return false; // Return false if $attribute is not valid
}
);

Expand Down
3 changes: 0 additions & 3 deletions includes/fbutils.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ class WC_Facebookcommerce_Utils {
const FB_VARIANT_PATTERN = 'pattern';
const FB_VARIANT_GENDER = 'gender';

const FB_DESCRIPTION = 'fb_description';
const WC_DESCRIPTION = 'wc_description';

public static $ems = null;
public static $store_name = null;

Expand Down

0 comments on commit ca0c1a4

Please sign in to comment.