Home Forums WoodMart support forum Compare Product in Woodmart Reply To: Compare Product in Woodmart

#167403

lnseldev
Participant

Hello,

I have earlier share you the snippet screenshot of the code in which we have modified the section to add the custom field. I am now sharing where we have modified in compare.php we have tried to do this in functions.php which doesn’t work as well.

Here is the code.

<div class=”woodmart-compare-table”>
<?php
//echo ‘

'; print_r($products); echo '

‘;
if ( ! empty( $products ) ) {
array_unshift( $products, array() );
foreach ( $fields as $field_id => $field ) {
if ( ! woodmart_is_products_have_field( $field_id, $products ) ) {
continue;
}
?>
<div class=”woodmart-compare-row compare-<?php echo esc_attr( $field_id ); ?>”>
<?php foreach ( $products as $product_id => $product ) : ?>
<?php if ( ! empty( $product ) ) : ?>
<div class=”woodmart-compare-col compare-value” data-title=”<?php echo esc_attr( $field ); ?>”>
<?php woodmart_compare_display_field( $field_id, $product ); ?>
</div>
<?php else: ?>
<div class=”woodmart-compare-col compare-field”>
<?php echo esc_html( $field ); ?>
</div>
<?php endif; ?>

<?php endforeach ?>
</div>
<?php
}
?>
<div class=”woodmart-compare-row compare-specification”>
<div class=”woodmart-compare-col compare-field”>
<?php echo ‘Specification’; ?>
</div>
<?php foreach ( $products as $product_id => $product ) : ?>
<?php if ( ! empty( $product ) ) : ?>
<div class=”woodmart-compare-col compare-value” data-title=”Specification”>
<?php //echo $product[‘id’];//woodmart_compare_display_field( $field_id, $product );
$product_tabs = maybe_unserialize( get_post_meta( $product[‘id’], ‘yikes_woo_products_tabs’ , true ) );
//echo ‘

'; print_r($product_tabs); echo '

‘;
echo $product_tabs[0][‘content’];
?>

</div>
<?php endif; ?>
<?php endforeach ?>

</div>
<?php
} else {
?>
<p class=”woodmart-empty-compare”>
<?php esc_html_e(‘Compare list is empty.’, ‘woodmart’); ?>
</p>
<?php if ( $empty_compare_text ) : ?>
<div class=”woodmart-empty-page-text”><?php echo wp_kses( $empty_compare_text, array(‘p’ => array(), ‘h1’ => array(), ‘h2’ => array(), ‘h3’ => array(), ‘strong’ => array(), ’em’ => array(), ‘span’ => array(), ‘div’ => array() , ‘br’ => array()) ); ?></div>
<?php endif; ?>
<p class=”return-to-shop”>
“>
<?php esc_html_e( ‘Return to shop’, ‘woodmart’ ); ?>

</p>
<?php
}

?>
<div class=”compare-loader”></div>
</div>

Please fix this concern ASAP as the site will be Go-live by Monday.

Best Regards