Add merchant logo to loop
This article explains how to add a merchant logo (if the logo exists in our database) to the store Loop like this:
- 1
-
Create a custom plugin
If you haven't done so already, create a custom plugin.
- 2
-
Add custom code
Add the following custom code to your custom plugin.
add_action( 'woocommerce_before_shop_loop_item_title', function () { global $product; if ( ! dfrpswc_is_dfrpswc_product( $product->get_id() ) ) { return; } $postmeta = get_post_meta( $product->get_id(), '_dfrps_product', true ); $title = esc_attr( $postmeta['merchant'] ?? '' ); $merchant = esc_html( $postmeta['merchant'] ?? '' ); $merchant_id = absint( $postmeta['merchant_id'] ?? 0 ); $url = esc_url( sprintf( 'https://images.datafeedr.com/m/%d.jpg', $merchant_id ) ); printf( '<object data="%s" type="image/jpeg" title="%s">%s</object>', $url, $title, $merchant ); }, 20 );