Skip to content

Instantly share code, notes, and snippets.

Avatar

Keylor Mendoza KeylorCR

View GitHub Profile
@KeylorCR
KeylorCR / wcpcd-functions.php
Last active Sep 11, 2020
Custom filters and functions for plugin WC Provincia-Cantón-Distrito
View wcpcd-functions.php
<?php
/**
** Adding custom json locations from child theme
** WC Provincia-Canton-Distrito
**/
function kmchild_prov_cant_dist_json($json_file) {
$json_file = get_stylesheet_directory_uri() . '/assets/js/prov-cant-dist.json';
return $json_file;
}
@KeylorCR
KeylorCR / wps-filterts.php
Last active Jul 27, 2020
List of filters included in the WC Pickup Store plugin. Check for filter availability in the plugin source code.
View wps-filterts.php
<?php
/**
** Add new content to be displayed in the template of
** store information in the Checkout page
** v1.5.23
** author: @keylorcr
**/
function keylorcr_wps_stores_fields($the_fields) {
foreach ($the_fields as $store_id => $value) {
$the_fields[$store_id][] = array(
View wc-extra-info-in-order-columns.php
<?php
/**
** Add extra information to admin order actions column
** @keylocr - 29-01-2020
**/
function wc_custom_admin_order_actions_end($object) {
$order_id = $object->get_id();
$store = (!empty(get_post_meta($order_id, '_shipping_pickup_stores', true))) ? get_post_meta($order_id, '_shipping_pickup_stores', true) : '';
if(!empty($store)) :
@KeylorCR
KeylorCR / wc-remove-address-pickup-store.php
Last active Jan 29, 2020
Remove woocommerce email addresses on wc_pickup_store shipping method
View wc-remove-address-pickup-store.php
<?php
function wc_removing_customer_details_in_emails($order, $sent_to_admin, $plain_text, $email) {
if ($order->has_shipping_method('wc_pickup_store')) {
$mailer = WC()->mailer();
remove_action( 'woocommerce_email_customer_details', array( $mailer, 'email_addresses' ), 20, 3 );
}
}
add_action('woocommerce_email_customer_details', 'wc_removing_customer_details_in_emails', 5, 4);
View update-checkout.js
/**
** After update checkout
**/
$(document.body).on('update_checkout, updated_checkout', function () {
validate_checkout_required_fields();
});
function validate_checkout_required_fields() {
if($('select.shipping_method').val() == "wc_pickup_store") {
$('#billing_state_field, #billing_city_field, #billing_address_1_field').find(".required").hide();
@KeylorCR
KeylorCR / wc-custom-functions.php
Created Jun 11, 2019
Adding superscript to wc_price filter <sup></sup>. Working to all prices throughout the site.
View wc-custom-functions.php
<?php
/**
** Adding superscript to wc_price <sup></sup>
** not working with prices into select2
**/
function custom_custom_price_format($return, $price, $args, $unformatted_price) {
$elements = explode('.', $price);
if(is_admin()) {
return $return;
@KeylorCR
KeylorCR / wps-get-custom-data.php
Last active Jul 27, 2020
These snippets allow you to get custom fields data from stores and show them in the order email or in the order item totals that appears on several parts of the WC site
View wps-get-custom-data.php
<?php
/**
** Get the store details and add them to order email
** below the order table
** WC Pickup Store plugin
** https://wordpress.org/plugins/wc-pickup-store/
**/
function custom_order_details_after_order_table($order) {
$order_id = $order->get_id();
$store_name = get_post_meta($order_id, '_shipping_pickup_stores', true); // Get store title for this order
@KeylorCR
KeylorCR / 0_reuse_code.js
Created Aug 30, 2017
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
You can’t perform that action at this time.