Skip to content
This repository has been archived by the owner on Mar 18, 2022. It is now read-only.

wc_get_template enhancements #10

Merged
merged 3 commits into from
Aug 23, 2018
Merged

wc_get_template enhancements #10

merged 3 commits into from
Aug 23, 2018

Conversation

mejta
Copy link
Contributor

@mejta mejta commented Aug 23, 2018

- Add rendering to 'woocommerce_before_template_part' hook (inspiration in https://github.com/kimhf/sage-woocommerce-support)
- Add local variables to template #6
- Render only when not in status screen #9
- Provide data access as suggested in #9
@mmirus
Copy link
Contributor

mmirus commented Aug 23, 2018

Thanks, @mejta. If this PR is ready to go, I can merge. All wrapped up?

@mmirus
Copy link
Contributor

mmirus commented Aug 23, 2018

Closes #9 and closes #6

@mejta
Copy link
Contributor Author

mejta commented Aug 23, 2018

Ready to merge @mmirus. Can you do a release with that, please? Thanks ;)

@mmirus mmirus merged commit 71564eb into roots:master Aug 23, 2018
@besrabasant
Copy link

Sorry for commenting here, But the Shop page now show blank.

@mejta
Copy link
Contributor Author

mejta commented Aug 25, 2018

@besrabasant Can you provide more details, please? I haven't experienced this issue so far on my e-commerce project. Thank you.

@besrabasant
Copy link

besrabasant commented Aug 25, 2018

@mejta It's nothing much... I just replaced all the .php template files with .blade.php and their contents with respective blade syntaxes. Before this update, the Shop page would show all the products listings, but after updating my project with this fix. the Shop shows just header and footer.

@mejta
Copy link
Contributor Author

mejta commented Aug 25, 2018

Can you please send me all overwriten templates, do i can simulate the issue on my environment? Thanks.

@besrabasant
Copy link

Sure @mejta. Here are the templates.

woocommerce.zip

@mejta
Copy link
Contributor Author

mejta commented Aug 27, 2018

Hi,

I've copied your template into my project and try that in functional e-commerce site locally. I have sage-woocommerce v1.0.3 and all plugins up-to-date. I also removed all cached compiled templates and the result is that I haven't found an error. The only page that is malformed is archive-page, I can see that processing of blade template was somehow interrupted (maybe some return or exit within the template), but there are so many templates to check manually and I don't have enough time.

Other pages work as expected, so I assume that it's not an error of this package, but some malformed template that is included.

Dan

@besrabasant
Copy link

@mejta So, I looked through the templates and found out that the bug is in the loop of archive-product.blade.php. Calling wc_get_template_part('content', 'product') does not work. And I even tried including the template using blade @include directive but no success. Hope, this might give you some insight.

@mejta
Copy link
Contributor Author

mejta commented Aug 28, 2018

Hi @besrabasant,

template content-product.blade.php should not extend layout. It's only a template part, not full page template. Please use @extends('layouts.app') only when you see get_header('shop') or get_footer('shop') in original template, that mean only in archive-product.blade.php and single-product.blade.php. This template should look like this:

@php
global $product;
@endphp

@if(!empty($product) && $product->is_visible())
  <li {!! wc_product_class() !!}>
    @php
    do_action('woocommerce_before_shop_loop_item');
    do_action('woocommerce_before_shop_loop_item_title');
    do_action('woocommerce_shop_loop_item_title');
    do_action('woocommerce_after_shop_loop_item_title');
    do_action('woocommerce_after_shop_loop_item');
    @endphp
  </li>
@endif

@besrabasant
Copy link

Hi @mejta, I tried the template snippet provided by you above but still no success.

@mejta
Copy link
Contributor Author

mejta commented Aug 28, 2018

Do you have any @extends or @section used in any other template that archive-product or single-product?

@besrabasant
Copy link

besrabasant commented Aug 28, 2018

No.

But Now I pinpoint the bug precisely. It's in the if statement inside the product loop. It doesn't go inside the loop, more precisely, There is no total prop in the WC Loop.

@mmirus
Copy link
Contributor

mmirus commented Aug 30, 2018

@besrabasant @mejta thanks both for your work on this. Is this something that should be addressed in this package, or something that just requires a change to the template code?

@besrabasant
Copy link

@mmirus Thank you for your appreciation. It seems this issue is related to this package.

@mmirus
Copy link
Contributor

mmirus commented Aug 31, 2018

Thanks, @besrabasant. @mejta - any thoughts on the new info above?

@besrabasant
Copy link

Hey @mejta @mmirus, the bug got fixed when I increased the number for products in the store. Previously, for testing purposes I had just 10 products. When I added some more products... Around 50... The shop Page started showing product listing. That's strange... Right?

@mmirus
Copy link
Contributor

mmirus commented Sep 4, 2018

Yes, that is strange. I wonder it it wasn't the number of products but something about a specific product or products.

I'm testing using the WooCommerce sample data that ships with the plugin and the template files you provided above (with the fix suggested by @mejta to content-product.blade.php) and still can't reproduce the problem, so it does seem like it could be related to your WC data or settings or something else that's not always present.

@mejta
Copy link
Contributor Author

mejta commented Sep 4, 2018

@besrabasant @mmirus I don't think it's a problem of this package, it seems as a problem of data/hook/or something.

@besrabasant
Copy link

besrabasant commented Sep 4, 2018

@mejta @mmirus Yeah, the problem is fixed and everything is working good now. Thanks for all your support on this 😃

@mmirus
Copy link
Contributor

mmirus commented Sep 4, 2018

Thanks both!

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants