Is it able to display item’s brand name in cart?
-
Hello,
I have install this plugin and works well!
However,I would like ask that is it able to add item’s brand(in text) in the shopping cart?
Thank you!The page I need help with: [log in to see the link]
-
Array
(
[home_url] => https://www.pask.com.tw
[site_url] => https://www.pask.com.tw
[version] => 3.9.1
[wp_version] => 5.3.2
[wp_multisite] =>
[wp_memory_limit] => 40M
[wp_debug_mode] =>
[wp_cron] => 1
[language] => zh_TW
[server_info] => Apache
[php_version] => 7.1.30
[php_post_max_size] => 128M
[php_max_execution_time] => 600
[php_max_input_vars] => 1000
[max_upload_size] => 134217728
[default_timezone] => UTC
[theme] => Array
(
[name] => Storefront
[version] => 2.5.1
[parent_theme] =>
)[active_plugins] => Array
(
[0] => livemesh-siteorigin-widgets/livemesh-siteorigin-widgets.php
[1] => a3-lazy-load/a3-lazy-load.php
[2] => add-from-server.php
[3] => advanced-woo-search/advanced-woo-search.php
[4] => akismet/akismet.php
[5] => auto-iframe/auto-iframe.php
[6] => awesome-widgets-for-siteorigin-page-builder/widget_activator.php
[7] => classic-editor/classic-editor.php
[8] => code-snippets/code-snippets.php
[9] => conditional-shipping-for-woocommerce/woo-conditional-shipping.php
[10] => dans-gdrive-viewer/dans-gdrive-viewer.php
[11] => dans-gsheets/dans-gsheets.php
[12] => duplicate-page/duplicatepage.php
[13] => duplicator/duplicator.php
[14] => ecpay-logistics-for-woocommerce/ECPay-shipping-integration.php
[15] => ecpay-payment-for-woocommerce/integration_plugin.php
[16] => enable-media-replace/enable-media-replace.php
[17] => final-tiles-grid-gallery-lite/FinalTilesGalleryLite.php
[18] => hello-dolly/hello.php
[19] => hide-featured-image/index.php
[20] => html-editor-syntax-highlighter/html-editor-syntax-highlighter.php
[21] => insert-pages/insert-pages.php
[22] => loco-translate/loco.php
[24] => megamenu-storefront/megamenu-storefront.php
[25] => megamenu/megamenu.php
[26] => page-links-to/page-links-to.php
[27] => perfect-woocommerce-brands/main.php
[28] => php-compatibility-checker/wpengine-phpcompat.php
[29] => post-types-order/post-types-order.php
[30] => really-simple-ssl/rlrsssl-really-simple-ssl.php
[31] => regenerate-thumbnails/regenerate-thumbnails.php
[32] => shortcodes-ultimate/shortcodes-ultimate.php
[33] => simple-facebook-plugin/simple-facebook-plugin.php
[34] => siteorigin-panels/siteorigin-panels.php
[35] => so-css/so-css.php
[36] => so-widgets-bundle/so-widgets-bundle.php
[37] => sp-news-and-widget/sp-news-and-widget.php
[38] => svg-support/svg-support.php
[39] => theme-customisations-master/theme-customisations.php
[40] => tinymce-advanced/tinymce-advanced.php
[41] => video-backgrounds-for-siteorigin-page-builder/background-videos-for-siteorigin.php
[42] => wc-category-locker/plugin.php
[43] => widgets-for-siteorigin/widgets-for-siteorigin.php
[44] => widgets-for-siteorigin/widgets-for-siteorigin.php
[45] => woo-category-discount/wildprog-woo-cat-discount.php
[46] => woo-checkout-field-editor-pro/checkout-form-designer.php
[47] => woo-gutenberg-products-block/woocommerce-gutenberg-products-block.php
[48] => woo-stickers-by-webline/woo-stickers-by-webline.php
[49] => woo-variation-swatches/woo-variation-swatches.php
[50] => woocommerce-admin/woocommerce-admin.php
[52] => woocommerce-max-quantity/woocommerce-max-quantity.php
[53] => woocommerce-product-carousel-slider-pro/wpcsp-main.php
[54] => woocommerce-stock-manager/woocommerce-stock-manager.php
[55] => woocommerce/woocommerce.php
[56] => wp-file-manager/file_folder_manager.php
[57] => wp-optimize/wp-optimize.php
)[pwb_options] => Array
(
[version] => 1.7.8
[wc_pwb_admin_tab_brand_single_position] => before_title
[old_wc_pwb_admin_tab_slug] => product_brand
[wc_pwb_notice_plugin_review] =>
[wc_pwb_admin_tab_slug] => product_brand
[wc_pwb_admin_tab_brand_desc] => yes
[wc_pwb_admin_tab_brand_single_product_tab] => no
[wc_pwb_admin_tab_brands_in_loop] => no
[wc_pwb_admin_tab_brands_in_single] => brand_image
[wc_pwb_admin_tab_brand_logo_size] => thumbnail
))
Hi paskcoltd,
You can try the code below:
add_filter( 'woocommerce_cart_item_name', function( $link_text, $cart_item, $cart_item_key ) { $_product = $cart_item['data']; $brands = implode(', ', wp_get_post_terms( $_product->get_id(), 'pwb-brand', ['fields' => 'names'] ) ); $link_text = '<div>' . __( 'Brand', 'perfect-woocommerce-brands' ) . ': ' . $brands . '</div>'; $product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $_product->is_visible() ? $_product->get_permalink( $cart_item ) : '', $cart_item, $cart_item_key ); if ( ! $product_permalink ) { $link_text .= $_product->get_name(); } else { $link_text .= sprintf( '<a href="%s">%s</a>', esc_url( $product_permalink ), $_product->get_name() ); } return $link_text; }, 10, 3 );
??
Hi @titodevera :
Thank you for the help!
I have add the codes and it works great!
Also I can make some style with it now.
Thanks again for the great work!solved
Perfect ??
- The topic ‘Is it able to display item’s brand name in cart?’ is closed to new replies.