Best place to add a Woocommerce single product page hook - wordpress

I need to add a section of boilerplate text about shipping info to the end of the WooCommerce single product page, right after the SKU and Categories. I would like to do this via hook if possible so I don't have to modify any WooCommerce code/template. The theme that I'm working with (Divi) has bunches of code already in functions.php, so I'd also like to avoid modifying that file, too.
My specific question is "what's the best place to add a WC hook for this purpose?" I know I could create a child theme and in its functions.php add a WC hook, but then I'd have the problem of calling in the original theme's functions.php (I don't know how to do that). Or is there a better way?

Try to create your own plugin
https://codex.wordpress.org/Writing_a_Plugin

Related

Issue with using [display-posts] shortcode on Wordpress

I am having an issue finding any way to display a single post on the woocommerce checkout specifically on a payment plugin, I use other shortcodes in these gateways and they work perfectly.
However when I try using some display post shortcodes it doesn’t work at all and instead shows up as text.
Example of my issue - i edit and put in the shortcode [display-posts] and instead of displaying the posts it simply displays [display-posts].
I have tried using multiple shortcode plugins and even tried creating my own. The main one I have tried to use is [display-posts] with the plug-in. I always put it in my themes functions.php as well!
I have tried these short codes on the regular Wordpress pages that I have that are published and have found I have the same issue, so I don’t believe it’s the placement I want the shortcode to appear at. Can anyone help me with this?
To make all the posts display you can create a custom shortcode and the shortcode which you are using is [display-posts] is not default WordPress in build shortcode. To have your same shortcode run please install the below plugin: https://wordpress.org/plugins/display-posts-shortcode/
Then you [display-posts] shortcode will work or another solution is custom shortcode as I mentioned above.
Please let me know if find any issues.
Thanks.

override woocommerce.php with custom content for only store homepage

I currently use FoundationPress (Foundation6) as framework and starter theme. It uses woocommerce.php template files to hook into woocommerce functionality but for the life of me I can't figure something out.
I need to add custom content to the stores homepage only, non of the other store pages. Whatever I add to woocommerce.php will appear on all store pages, but I can't figure out what template controls the stores homepage.
The first set of templates I can see are used are the ones that are inthe loop folder and content-product.php. Normally I would just edit archive-product.php but woocommerce.php takes over from this template: see bottom of https://docs.woocommerce.com/document/template-structure/.
The shop is archive-product. However I did not try FundationPress but it seems that WooCommerce needs in the last version to declare WooCommerce support in themes. https://github.com/woocommerce/woocommerce/wiki/Declaring-WooCommerce-support-in-themes
So first try https://en-gb.wordpress.org/plugins/query-monitor/ and check which template is loading. And if its loading page.php instead of Woocommerce template implement the line in functions.php.

How to change Woo Commerce page in wordpress

I am trying to get rid of the information displayed above the actual check out page. It shows me Welcome Admin, and contact numbers and email. I want to change those details.
The checkout page in wordpress only shows a shortcode for [woocommercepage_checkout], which css should i go to ?
Cheers
You can use a hook to which you can add your custom css.(A helpful like for this would be WP_ENQUEUE_STYLE)
In the hook function you can register and enqueue your custom css file. In order to ensure that your custom CSS won't desrupte other page's styling write your enqueuing line in a conditions like is is_checkout().
All this code you need to add in your theme's functions.php or you can add this in your custom plugin.
Later all styling part can be handled in the css file which you register and enqueue.
This way you can Elegantly deal with the styling in a WordPress way.

WooCommerce custom checkout page in theme

Is it possible to create custom checkout page in my theme? I mean to create custom checkout.php document I do not want to edit WooCommerce default theme.
Yes, this is achieved by overriding the WooCommerce checkout.php file in the plugin itself by placing it in your theme's WooCommerce directory. You are right not to want to edit the plugin because any updates will render such changes obsolete. You can see the following files you would want to override here: https://github.com/woothemes/woocommerce/tree/master/templates/checkout
Your directory should look something as follows:
themeroot/
single.php
page.php
etc..
woocommerce/
templates/
checkout/
form-checkout.php
form-billing.php
etc
You can learn more about creating Custom WordPress themes by viewing the document. You will want to duplicate and work of these files to create your custom checkout page.

how to add a button in the [add to cart] side?

photo http://sleekupload.com/uploads/5/nb.png
How to write in functions.php
https://wordpress.org/plugins/woocommerce/
The hook that you are looking for is woocommerce_after_add_to_cart_button. To write a function, please review WordPress Plugin API. If this is too confusing, you have the option of editing the templates themselves by going to /wp-content/plugins/woocommerce/templates/single-product/ then you can do a search for woocommerce_after_add_to_cart_button. Keep in mind that updating WooCommerce may erase those templates so I advice you to keep your template files in your theme instead.

Resources