This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function cs_woocommerce_locate_template( $template, $template_name, $template_path ) { | |
global $woocommerce; | |
$_template = $template; | |
if ( ! $template_path ) { | |
$template_path = $woocommerce->template_url; | |
} | |
$plugin_path = untrailingslashit( plugin_dir_path( __FILE__ ) ) . '/templates/'; | |
// Look within passed path within the theme - this is priority |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add order again button in my orders actions. | |
* | |
* @param array $actions | |
* @param WC_Order $order | |
* @return array | |
*/ | |
function cs_add_order_again_to_my_orders_actions( $actions, $order ) { | |
if ( $order->has_status( 'completed' ) ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: PAC Gratuito | |
* Plugin URI: https://claudiosmweb.com/woocommerce/woocommerce-deixar-o-metodo-de-entrega-pac-dos-correios-gratuito/ | |
* Description: Deixa o valor do PAC do WooCommerce Correios sempre como gratuito. | |
* Author: Claudio Sanches | |
* Author URI: http://claudiosmweb.com/ | |
* Version: 1.0.0 | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function rand_related_products_query( $query ) { | |
$query['limits'] = ' ORDER BY RAND() ' . $query['limits']; | |
return $query; | |
} | |
add_filter( 'woocommerce_product_related_posts_query', 'rand_related_products_query' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: WooCommerce Remove billing fields | |
* Description: Remove billing address, fone and company fields from WooCommerce checkout. | |
* Author: Claudio Sanches | |
* Author URI: https://claudiosmweb.com | |
* Version: 0.0.1 | |
* License: GPLv2 or later | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'rest_api_init', function() { | |
register_rest_route( 'my-route/v1', '/products/(?P<id>\d+)', array( | |
'methods' => 'GET', | |
'callback' => function( $data ) { | |
$product = wc_get_product( $data['id'] ); | |
if ( empty( $product ) ) { | |
return null; | |
} | |
return $product; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Custom variable price HTML. | |
* Shows "Starting at" prefix with when min price is different from max price. | |
* | |
* @param stirng $price Product price HTML | |
* @param WC_Product_Variable $product Product data. | |
* @return string | |
*/ | |
function cs_my_wc_custom_variable_price_html( $price, $product ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Hide the "In stock" message on product page. | |
* | |
* @param string $html | |
* @param string $text | |
* @param WC_Product $product | |
* @return string | |
*/ | |
function my_wc_hide_in_stock_message( $html, $text, $product ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Custom WooCommerce tag cloud shortcode. | |
* | |
* Use the follow shortcode in your pages: [my_wc_tag_cloud] | |
*/ | |
function my_custom_wc_tag_cloud_shortcode() { | |
return wp_tag_cloud( array( 'taxonomy' => 'product_tag', 'echo' => false ) ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: WooCommerce Installments Example | |
* Plugin URI: http://claudiosmweb.com/ | |
* Description: Added the price with 3 installments without interest. | |
* Author: claudiosanches | |
* Author URI: http://www.claudiosmweb.com/ | |
* Version: 1.0 | |
* License: GPLv2 or later | |
*/ |