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

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.

Related

How to modify WP Job Manager job listings template?

Long story short - where is the template for the listing list items that are shown when the [jobs] shortcode is used?
I have a WP site with WP Job Manager. I am using the [jobs] shortcode to show a list of the jobs that is searchable. I need to modify the template of the listings to show lets say an excerpt of the job offer. I think the template showing there is the content-job_listing.php, but when I modify it nothing happens. So my problem is I can't seem to find the correct template.
I've searched the whole plugin code and can't seem to find anything remote to what is displayed on my page where the [jobs] shortcode is.
So what is happening here you think and where usually is the template I am looking for?
content-job_listing.php ist the corect template for it. What theme are you using? If you are using a WP Job Manager specific theme like Jobify then they probably have a custom template overriding the plugin's template. Then you'd have to look in their documentation to see which file that is.
Where are you editing the file? In a child theme or in the plugin's folder? If you are editing the file in the plugin's folder and you don't see changes then you probably have the file in a child theme as well. The child theme takes priority in that case.
Anyway you should make changes only in a child theme and not in the plugin files to make sure your changes are update-proof. It could also be that you are editing the file in a child theme which is not the active theme in your WP install?
If you haven't done yet check out the official WPJM documentation on this topic: https://wpjobmanager.com/document/template-overrides/

Where do I put hooks for Contact Form 7 on Wordpress?

I'm a complete Wordpress Newbie and I'm confused on exactly how hooks work. I've been trying to use Contact Form 7 to send information to an external database, and so far I've found a plugin that seems to do exactly that. But where exactly should I be putting this code?
In WordPress, you can add a hook or filter in two ways.
Create your own plugin and add your code so whenever the site load or hook call the code will be executed.
For example, the link you have added plugin.
You can add the same code in your theme file function.php
Both option has it prons and crons.

Editing a WordPress plugin

I'm trying to edit a WordPress plugin. My conventional thinking is telling me to edit HTML but I know WordPress is PHP. I'm not talking about CSS editing either (aesthetics, positioning, color...etc). I know how to do that.
For example let's say I have a plugin Form with an input box with the title "how much" however I want it to say something else like "Dollars"....how do I do this?
Also the plugin admin area doesn't give me the option to change this in the backend. Isn't there another way to change that?
Ways to do it:
Search for the string in the plugin's files and check if it offers a filter hook (apply_filters), if it does create a plugin or use functions.php.
Use another plugin to modify the string.
If the plugin has internatinaliztion support, create a translation file for your language and translate only that string. Use en_US if your WPLANG is empty.
Hack the plugin itself and change the string (bad, this has to be done at each plugin upgrade).

Contact form 7 hooks, where can we write it to take it's advantage

In wordpress I have comeaccross the word hooks, I have implemented few of them in my custom theme's function.php, I am trying to edit someone's code, I see he wrote few hooks inside the plugins settings.php file itself.
ex- We are using the plugin Contact Form 7, and wanted to add some more data to email before sending them, hence he wrote the hooks inside settings.php which I am not sure is correct or wrong.
Can some-one advice me as what is the best place to write our hooks for wordpress plugins so that it will not affect the plugin when there is an upgrade.
Continue to use functions.php. If it starts to become a bit cluttered separate into includes. ie...
include_once('inc/cf7_custom.php');

Modifying WordPress plugin markup

Is there a 'good working practise' way to modify the markup that a WordPress plugin produces without editing the plugin's core files. The problem I foresee is that when you update the plugin, the markup that you would have modified overwritten.
I know in Drupal there are template overrides, but I don't know enough about WordPress to do a similar practise.
Any help?
The plugin itself would probably have to be written to allow for it (though see below). There are a few ways to do this: You could have the plugin look for template files that it pulls from an arbitrary location (e.g. "uploads/myplugin") You could possibly store the HTML in the database as a setting. The plugin could be written with an apply_filter hook (just as WordPress itself uses hooks) to allow outside calls that change output (e.g. from a separate plugin or a theme's functions.php). I've used all of these methods.
If you're talking about altering the output of somebody else's plugin, you could possibly ask them to implement one of the above. Push comes to shove you can use JavaScript to manipulate the DOM.
The answer to your question is hooks and templates. If you're lucky, the plugin will use templates for its output and will check your theme to see if you've overridden them, or it may have some filter hooks that let you modify its output. If you're not so lucky, and you can't get the plugin authors to add some for you, you'll need to get more creative.
hook into the WordPress queries that the plugin is
making, and alter them to return different results.
hook into the WordPress get_option() function to change the plugin's settings on the fly.
hook into the page content, and use preg_replace() to hack the HTML.
hook in early in the page generation, call ob_start() to buffer the page output, and hook the wp_footer to call ob_end_clean() and use preg_replace() to hack the HTML.
Just some ideas :)
Obviously, it's best to work with the plugin than against it. You should check to see whether your plugin uses templates, and if it doesn't, search for calls to apply_filter() and do_action(). But sometimes, needs must!

Resources