Skip to content

Instantly share code, notes, and snippets.

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

Hendra Setiawan hendcorp

🏠
Working from home
View GitHub Profile
@hendcorp
hendcorp / functions.php
Last active January 21, 2019 09:33
Override WooCommerce Shipping Cost
<?php
add_filter( 'woocommerce_package_rates', 'override_ups_rates' );
function override_ups_rates( $rates ) {
foreach( $rates as $rate_key => $rate ){
// Check if the shipping method ID is UPS
if( ($rate->method_id == 'flexible_shipping_ups') ) {
// Set cost to zero
$rates[$rate_key]->cost = 0;
}
}
@hendcorp
hendcorp / functions.php
Last active August 23, 2017 17:04
WooCommerce : Disable Autofocus on the First Name field under Billing and Shipping address.
<?php
/* Disable autofocus on the billing First Name field */
add_filter('woocommerce_billing_fields','disable_autofocus_billing_firstname');
function disable_autofocus_billing_firstname($fields) {
$fields['billing_first_name']['autofocus'] = false;
return $fields;
}
/* Disable autofocus on the shipping First Name field */
add_filter('woocommerce_shipping_fields','disable_autofocus_shipping_firstname');
<?php
public function musicetrade_set_price($price, $product) {
global $product;
$product_id = $product->get_id();
$seller_currency = self::get_pv_shop_currency(self::get_product_vendor_id($product_id),self::shop_base_currency());
$active_currency = get_woocommerce_currency();
if( $active_currency != $seller_currency ) {
//if active currency and vendor's currency are different, do the conversion
$etrade_price = round(self::convert($price, $active_currency, $seller_currency));
@hendcorp
hendcorp / class-wcv-simple-auctions.php
Last active August 12, 2017 16:02
WC Vendors Simple Auction - Date Generator
<?php
//Start Date - Set default to todays date
update_post_meta( $post_id, '_auction_dates_from', stripslashes( date('Y-m-d H:i') ) );
//End Date - conditional
if (isset($_POST['_auction_duration'])):
$aucdur = $_POST['_auction_duration'] + 1;
$duration = "+".$aucdur." day";
update_post_meta( $post_id, '_auction_dates_to', stripslashes( date('Y-m-d H:i', strtotime($duration)) ) );
endif;
@hendcorp
hendcorp / class-wcv-simple-auctions.php
Last active August 12, 2017 16:01
WC Vendors Simple Auction - Form Helper
<?php
// Auction Duration
WCVendors_Pro_Form_Helper::select( apply_filters( 'wcv_simple_auctions_auction_duration', array(
'post_id' => $post_id,
'id' => '_auction_duration',
'label' => __( '<i class="fa fa-calendar"></i> Duration', 'wc_simple_auctions' ),
'class' => 'form-control',
'desc_tip' => 'true',
'description' => sprintf( __( 'Select how long your listing will run.', 'wcvendors-pro-simple-auctions' ) ),
'wrapper_start' => '<div id="duration-box" class="column large-6">',
@hendcorp
hendcorp / functions.php
Last active October 19, 2021 11:41
AfterShip webhook for WordPress
<?php
//Aftership Automatic Tracker
add_action('wp_head','trackship_catcher');
function trackship_catcher() {
if(isset($_GET['webhook-listener']) && $_GET['webhook-listener'] == 'trackship') {
//Get and decode JSON
$str = file_get_contents("php://input");
$json = json_decode($str, true);