Navigation überspringen

[Gelöst] Customize Woocommerce Category Page

This support ticket is created vor 4 Jahren, 10 Monaten. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Dieses Thema enthält 7 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Waqar vor 4 Jahren, 10 Monaten.

Assistiert von: Waqar.

Author
Artikel
#1504019

Hey guys, I have used Woocommerce Views to successfully customize the Woocommerce Product pages.

But now I want to customize the Woocommerce Product Category page. I have tried to create a WordPress Archive for the Product category taxonomy, but the Woocommerce shop page still shows the standard view:
versteckter Link

What am I missing?

Thanks Tobi

#1504033

To clarify:
I am talking about the categories on the 'main shop page':
versteckter Link

When I click on one to the categories, then the taxonomy page (that I altered with toolset) shows up (instead of the products):
versteckter Link

I am expecting to see the taxonomy page on the main shop page and when I click on one of the links this should take me to the single product.

Thanks

#1505019

Hi Tobi,

Thank you for contacting us and I'd be happy to assist.

I noticed that in your website's WooCommerce settings, "Show categories" and not "Show products" option is selected for the shop page.
( you'll find this option at WP Admin -> Appearance -> Customize -> WooCommerce -> Product Catalog )

Since the WordPress Archive View for Products post type is designed to show products, it is not applied to the shop page, when product categories are showing, instead of the products.

To make sure your custom product archive from Toolset is applied to your shop page, you can change that option to "Show products".

After that, If you'd like to show the list of product categories on that shop page, you can create a new taxonomy view that shows the product categories and include it inside your product archive view, but outside the main loop.

Note: Since nested views are not supported when using the block's editor, you'll need to switch to the classic editor for the product post type archive.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1513705

Hey Waqar. Thx a lot for your help. Well, I‘ve achieved siomething similar here. But what I still do not understand is:

- how can I change the look, layout and what to show on the category page here:
versteckter Link

I would like to change the layout so it looks more like this:

versteckter Link
(I was able to control the look and layout of this one with the toolset wordpress archive tenplate for product category)

Isnt there a similar way to control the main category?

Thx a lot for your help!
Tobias

#1517547

Hi Tobias,

Thanks for writing back.

Since the new Blocks interface currently doesn't support taxonomy views or nested views, this requirement is turning out to be more complex.

I'll be performing some tests on my own website and will share my findings as soon as this completes.

Thank you for your patience.

regards,
Waqar

#1528363

Hi Tobias,

Thank you for waiting and sorry about the delay in getting back on this.

I've performed some tests on my own website and this is the workaround that I'll suggest, to design the shop page ( versteckter Link ) similar to the product category archive pages ( e.g. versteckter Link )

1. Currently, the "Products" WordPress Archive is set for both, the "Products (post type archive)" and the "Product categories (taxonomy archive)".

From the "WordPress Archive" block setting, keep it selected for the "Product categories (taxonomy archive)", but not for the "Products (post type archive)".
Screenshot: versteckter Link

2. Next, go to WP Admin -> Appearance -> Customize -> WooCommerce -> Product Catalog and for "Shop page display" select "Show products". This will ensure that the new WordPress Archive that we're going to create in the next step is applied to the shop page.

3. After that, please go to WP Admin -> Toolset -> Settings -> General and select "Show both the legacy and Blocks interface and let me choose which to use for each item I build" for the "Editing experience" field.

Also, select "Classic Editor" for "Editor to use for Content Templates" and "Editor to use for WordPress Archives" fields.

4. From WP Admin -> Toolset -> WordPress Archives (using the classic editor), create a new archive for the "Products" post type archive but keep the content of the loop in the loop editor section empty, as we don't want to show products on this shop page:

Example:


[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<wpv-loop>
	</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

5. From WP Admin -> Toolset -> Views, create a new taxonomy view to show "Product Categories" and you can design its output in the "Loop Editor" section to match the output of your product category archive page like this:


[wpv-layout-start]
	[wpv-items-found]
	<div class="js-wpv-loop-wrapper">
	<ul class="wpv-loop js-wpv-loop">
	<!-- wpv-loop-start -->
		<wpv-loop>
		<li>
			<div class="wp-block-toolset-views-view-template-block wpv-block-loop-item php-to-be-replaced-with-shortcode">
				<div class="wp-block-columns are-vertically-aligned-center">
					<div class="wp-block-column is-vertically-aligned-center" style="flex-basis:15%">
						<div class="tb-field tb-field--left">
							[get_terms_thumbnail id="[wpv-taxonomy-id]" title="[wpv-taxonomy-title]" class="attachment-custom aligncenter"]
						</div>
					</div>
					<div class="wp-block-column is-vertically-aligned-center" style="flex-basis:67.5%">
						<div class="tb-field tb-field--left">
							<a href="[wpv-taxonomy-url]">[wpv-taxonomy-title]</a>
						</div>
					</div>
					<div class="wp-block-column" style="flex-basis:17.5%">
						<div class="tb-button tb-button--center">
							<a class="tb-button__link" href="[wpv-taxonomy-url]">
								<i class="tb-button__icon"></i>
								<span class="tb-button__content">learn more</span>
							</a>
						</div>
					</div>
				</div>
				<hr class="wp-block-separator is-style-wide">
			</div>
		</li>
		</wpv-loop>
	<!-- wpv-loop-end -->
	</ul>
	</div>
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

6. You'll need to register a custom shortcode [get_terms_thumbnail] that we've used in the last step, to get the image thumbnail from the product categories:


add_shortcode('get_terms_thumbnail', 'get_terms_thumbnail_func');
function get_terms_thumbnail_func($atts) {

	$a = shortcode_atts( array(
		'id' => '',
		'title' => '',
		'class' => ''
	), $atts );

	$thumbnail_id = get_term_meta( $a['id'], 'thumbnail_id', true );

	$image = wp_get_attachment_url( $thumbnail_id );
	if ( $image ) {
		return '<img src="'.$image.'"alt="'.$a['title'].'"class="'.$a['class'].'" />';
	}
}

Note: This new shortcode accepts three parameters: id, title, and class and the above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through active theme's "functions.php" file.

7. The last step would be to include this taxonomy view's shortcode at the start of content in the "Loop Editor" section of the WordPress Archive for the products post type archive, created in step 4.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1534617

Thx so much Waqar for this thorough reply. I will need some time to try this out and will get back to you as soon as I know more, until then, thx so much! Great support.

#1534927

You're very welcome Tobias and please let me know if you have any follow-up questions.

For a new/different question or concern, you can start a new ticket.