S
S
someden2015-05-21 18:00:20
CMS
someden, 2015-05-21 18:00:20

How to make a theme for woocommerce?

In the documentation
docs.woothemes.com/document/template-structure
I found that you can copy the
/plugins/woocommerce/templates/ templates
folder to your theme folder, rename it to woocommerce
/themes/mytheme/woocommerce/
And then change these templates.
But I downloaded themes from woothemes (native themes, so to speak), for example, storefront and mystile, and everything is different in them, there are no templates already, how is the layout integrated? Unclear. That is, they themselves make templates for themselves not as advised in the documentation?
I started to make a theme as they advise in the documentation. I had a simple task, I need to add a class to the "Proceed to Checkout" button in the cart, I open the cart template file woocommerce/cart/cart-totals.php and see there

<?php do_action( 'woocommerce_proceed_to_checkout' ); ?>

instead of a simple link.
So, instead of just changing the link, I need to override this function in the functions.php file.
Why such a division? Why make small elements like buttons and links in the form of do_action and put them in a completely different place, and not leave them where they should be displayed?
Farther. I wanted to swap the price and the "Add to cart" button, I go to the file of the corresponding template and see
<?php
  /**
   * woocommerce_single_product_summary hook
   *
   * @hooked woocommerce_template_single_title - 5
   * @hooked woocommerce_template_single_excerpt - 20
   * @hooked woocommerce_template_single_rating - 25
   * @hooked woocommerce_template_single_price - 25
   * @hooked woocommerce_template_single_add_to_cart - 30
   * @hooked woocommerce_template_single_sharing - 50
   */
  do_action( 'woocommerce_single_product_summary' );
?>

As a result, half of the theme is in my function.php file, and now it is full of lines like:
remove_action("...");
add_action("...");
remove_action("...");
add_action("...");

But woothemes people are probably smarter than me, so what am I missing? Is it some kind of pattern or what? How is it more convenient?
And how do I make the theme so that if I need to change the html in the cart, I go to the cart template and change, and not look for the corresponding function somewhere else?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WP Panda, 2015-05-22
@someden

The guys from WooThemes are really fire, but they do not do it so smoothly for another reason. They Produce both the plugin and the theme, so why would they want to include the plugin in the theme if they're happy with it anyway?
If you want to change everything, then this is exactly the path you copy the templates folder, and change everything in it, but you don’t need to copy the entire folder, but exactly the templates that you change, why load the theme with unnecessary files,
I have it set up like
this I take out in a separate file.
As for the rest, WooCommerce is cool in that it can be twisted as you like, and that is why filters and actions are used there to the fullest.
And in general, the use of these features, there is a good tone when developing, for example, I develop everything on my own framework, all actions are taken out in a separate file, which allows me to bend the project in any direction without any extra gestures.
d99cde57a7.jpg

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question