Woocommerce plugin extending coupons - woocommerce

I am in the process of writing a plugin for woocommerce. For the plugin I'd like to have a field where people can fill in a special code. Basically a coupon. This code will need to be checked against my own api to make sure it's a valid code.
I've tried to find some docs and information on how to add your own coupons. I've browsed through
https://docs.woocommerce.com
Looking for some api to add a hook to a custom function when it checks the coupon but could not find any.
Maybe I am approaching this wrong.
Does anyone know of some docs or an extension that has already done this to get me started?

Related

Divide checkout field in woocomemrce

I need to totally customise WooCommerce checkout page. I can do a lot of things with Woocommerce programatically but this one is not an easy task since I need to divide these fields just like on the picture below.
Website is on this link: https://2houragency.com/. I can see that they have hidden some default Woocommerce HTML elements and created their own, but I am not sure how to do it by myself. And Wocommerce is not that easy to customise for this kind of pages.
Get into the templating documentation of WooCommerce here.
You'll probably want to use one of these template files to re-order/structure the checkout template.
You can find even more information in the Code Refference.

How to create Child Plugin for wordpress

Actually I have changed some code in WordPress Store Locator. I want it to remain when plugin will update. So I want to create a child plugin for that. Any ideas on how I could manage it?
This varies plugin to plugin, and it sometimes isn't even possible, other times plugins have documentation to extend them easily (such as WooCommerce and Gravity Forms). Some of them create Action Hooks with do_action() that let you extend the functionality easily. A common example is updating a post after a Gravity Form is submitted with their gform_after_submission hook.
Effectively, it depends on what you want to do, and how the plugin implements the functionality you want to change. If they add text with a Closure or Anonymous Function, it will be harder to modify said text, and you may have to look at something strange like doing a run-time find and replace using Output Buffering, typically on the template_redirect hook.
If you want to remove something a plugin does, you can often unhook it with remove_action. This can be a bit tricky depending on how the plugin is instantiated, sometimes its as simple as:
remove_action( 'some_hook', 'function_to_remove' );
Other times it's more complicated like:
global $plugin_class_var;
remove_action( 'some_hook', array($plugin_class_var, 'function_to_remove') );
Those are the basics of extending (or even 'shrinking'?) a plugin's functionality, and it's not always doable appropriately. Unfortunately the narrow answer to your question is outside of the scope of what we can provide from StackOverflow.
From here, you'll need to figure out exactly what you want to do with the plugin, and dig through the plugin's files to see if there's an appropriate hook or function you can use. If you're still stuck, you'll need to post a new question (don't update this one) with your exact desired result and anything you've tried, and the relevant code that goes along with it. "I want to change a plugin without editing core files" isn't nearly specific enough. "I want to replace an icon with a custom icon in this plugin, here's what I've tried" is specific enough to possibly answer.
Good luck!
I just went through myself and I had so many changes that I couldn't just override the actions.
I created this tool that allows you to create a child plugin like a child theme. You can make updates to the plugin and still update it without losing your changes.
I'm posting this here because it relates and hopefully becomes useful to the next person who runs into this issue.
https://github.com/ThomasDepole/wordpress-child-plugin-tool
As per WordPress standard, it's called plugin's addon.
if the plugin has provided any action to update that functionality then you can use it with your addon (child plugin).
Here I am sending a link for reference.
https://developer.wordpress.org/reference/functions/add_action/

WordPress admin area search not working

Currently I have an installation of WordPress that is running a plugin called Types. When I search for posts inside a custom post type I get no results at all. The URL string looks correct:
&action=-1&m=0&seo_filter&paged=1&mode=list&action2=-1
But it returns nothing.
Additionally, when I remove &action=-1, the search results show up correctly. I have tried disabling the plugin and it works correctly, however I have other sites using the same plugin and searching works on these.
Does anyone have any ideas on how to fix this?
Read - Yoast's guide on integrating Gravity Forms to realise the greatness of this plugin.
It has a paid limitation on assigning role capabilities to custom post types which can be partially fulfilled with http://wordpress.org/plugins/map-cap/
It would probably be best asking the plugin developer in the WP Support forum.
http://wordpress.org/support/plugin/types

Woocommerce Coupons, Free product on order when code is entered. Possible?

So as the name suggests I would like to know if its possible to Have a coupon set up on woocommerce that when entered at the checkout it adds in a free product to the order.
Can this be done or is this something woocommerce could not handle.
If anyone knows of any plugins etc I would be extremely grateful
From your question, you are asking if there's a way for users to enter a coupon that when entered gives free products?
It is possible with Woocommerce, out of the box it has it's coupon management. You can even exclude products which is useful!
Read more about this here http://docs.woothemes.com/document/coupon-management/
It's very simple to get up and running!
I realize this question is old but figured I would point out there's a plugin available for rather cheap that can handle this. I'm not the author, nor do I use the plugin, but it should take care of this functionality:
http://codecanyon.net/item/woocommerce-free-gift/6144902

How can I set WordPress roles such that once a Contributor's post is scheduled to be published, they can no longer edit it?

At least for my purposes, it is absolutely essential that a Contributor be unable to edit his posts once they've been scheduled to be published, as well as actually published.
This seems like it should be simple because otherwise in a system with a lot of users a malicious user could slip under the radar with a sketchy post by first submitting an innocuous one and then right before it is scheduled to be published, edit it.
None of the role-editing plugins I've tried seem to have this functionality.
You need to create a filter function add hook it.
You may want to read "WordPress tip: Allow contributors to upload files" at http://www.wprecipes.com/wordpress-tip-allow-contributors-to-upload-files to get an idea.
The filter hook you'll need is the "format_to_edit" hook. Please refer to http://codex.wordpress.org/Plugin_API/Filter_Reference for details.
That filter hook isn't what you want. Let me think about it.

Resources