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
| // Get The Page ID You Need | |
| get_option( 'woocommerce_shop_page_id' ); | |
| get_option( 'woocommerce_cart_page_id' ); | |
| get_option( 'woocommerce_checkout_page_id' ); | |
| get_option( 'woocommerce_pay_page_id' ); | |
| get_option( 'woocommerce_thanks_page_id' ); | |
| get_option( 'woocommerce_myaccount_page_id' ); | |
| get_option( 'woocommerce_edit_address_page_id' ); | |
| get_option( 'woocommerce_view_order_page_id' ); | |
| get_option( 'woocommerce_terms_page_id' ); |
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
| //enable COD only for italy | |
| function payment_gateway_disable_country( $available_gateways ) { | |
| global $woocommerce; | |
| if ( isset( $available_gateways['cod'] ) && $woocommerce->customer->get_country() <> 'IT' ) { | |
| unset( $available_gateways['cod'] ); | |
| } | |
| //make COD the only available gateway for flat_rate shipping method (or other unused method) | |
| //you can use the label cash on delivery for flat_rate and determining the shipping cost for COD | |
| $chosen_methods = WC()->session->get( 'chosen_shipping_methods' ); |
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
| /* | |
| * Disable PayPal payment method in the checkout if certain | |
| * products are present in the cart. | |
| * | |
| * Add this to your theme's functions.php file | |
| */ | |
| add_filter( 'woocommerce_available_payment_gateways', 'filter_gateways', 1); | |
| function filter_gateways( $gateways ){ | |
| global $woocommerce; |
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 custom_woocommerce_loop_add_to_cart_link( $html, $product ) { | |
| return '<a href="' . get_permalink( $product->id ) . '" class="button">' . __( 'Texto do botão' ) . '</a>'; | |
| } | |
| add_filter( 'woocommerce_loop_add_to_cart_link', 'custom_woocommerce_loop_add_to_cart_link', 10, 2 ); |
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 // only copy this line if needed | |
| /** | |
| * Adds product images to the WooCommerce order emails table | |
| * Uses WooCommerce 2.5 or newer | |
| * | |
| * @param string $output the buffered email order items content | |
| * @param \WC_Order $order | |
| * @return $output the updated output | |
| */ | |
| function sww_add_images_woocommerce_emails( $output, $order ) { |
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 | |
| /** | |
| * start the customisation | |
| */ | |
| function custom_woo_before_shop_link() { | |
| add_filter('woocommerce_loop_add_to_cart_link', 'custom_woo_loop_add_to_cart_link', 10, 2); | |
| add_action('woocommerce_after_shop_loop', 'custom_woo_after_shop_loop'); | |
| } | |
| add_action('woocommerce_before_shop_loop', 'custom_woo_before_shop_link'); |
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
| /* To use: | |
| 1. Add this snippet to your theme's functions.php file | |
| 2. Change the meta key names in the snippet | |
| 3. Create a custom field in the order post - e.g. key = "Tracking Code" value = abcdefg | |
| 4. When next updating the status, or during any other event which emails the user, they will see this field in their email | |
| */ | |
| add_filter('woocommerce_email_order_meta_keys', 'my_custom_order_meta_keys'); | |
| function my_custom_order_meta_keys( $keys ) { | |
| $keys[] = 'Tracking Code'; // This will look for a custom field called 'Tracking Code' and add it to emails |
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 | |
| // Place the following code in your theme's functions.php file to add the shipping method to all emails | |
| add_action( 'woocommerce_email_after_order_table', 'wc_add_shipping_method_to_emails', 15, 2 ); | |
| function wc_add_shipping_method_to_emails( $order, $is_admin_email ) { | |
| echo '<p><strong>Shipping Method:</strong> ' . $order->get_shipping_method() . '</p>'; | |
| } | |
| // Place the following code in your theme's functions.php file to add the shipping methid to admin emails only | |
| add_action( 'woocommerce_email_after_order_table', 'wc_add_shipping_method_to_admin_emails', 15, 2 ); | |
| function wc_add_shipping_method_to_admin_emails( $order, $is_admin_email ) { |
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
| // Redirect customers to another page with your personal thoughts and thank you message instead of woocommerce default thank you page. | |
| add_action( 'template_redirect', 'wc_custom_redirect_after_purchase' ); | |
| function wc_custom_redirect_after_purchase() { | |
| global $wp; | |
| if ( is_checkout() && ! empty( $wp->query_vars['order-received'] ) ) { | |
| wp_redirect( 'http://www.yoururl.com/your-page/' ); | |
| exit; | |
| } | |
| } |