Skip to content

Instantly share code, notes, and snippets.

View dgaitan's full-sized avatar
🏠
Working from home

David Gaitán dgaitan

🏠
Working from home
View GitHub Profile
@dgaitan
dgaitan / retrieving-an-order.php
Created July 11, 2022 13:54
WordPress Order Object
<?php
// Retrieving a simple order
$order = wc_get_order( 1234 );
// Then we can get info related to this order by running.
$order->get_id();
$order->get_total()
// Also we could retrieve a collection of orders by running.
<?php
/**
* See the next link to understand more about this filter hook.
*
* @see https://developer.wordpress.org/reference/hooks/the_content/
* @param string $content - the post content.
* @return string $content - the content updated
*/
function add_footer_to_post_content( $content ) {
<?php
/**
* See the following link to know the arguments passed by this action.
*
* @see https://developer.wordpress.org/reference/hooks/post_updated/
* @param int $post_ID - the post ID updated
* @param WP_Post $post_after - Post content after updated
* @param WP_Post $post_before - Post content before updated.
*/
<?php
/**
* An action hook recives four params.
*
* @param string $hook_name - The name of the hook
* @param callable $callback - The callback where we are going to add our logic.
* @param int $priority - The priority of the hook. Used to specify the order in which the functions associated with a particular action are executed.
* @param int $params - The number of arguments the function accepts
*/