Skip to content

Instantly share code, notes, and snippets.

@bporcelli
bporcelli / payouts-trigger-payout-on-order-complete.php
Created January 15, 2022 19:50
[Payouts] Shows how to trigger a payout of all commissions when an order is marked completed
<?php
use WCV_Payouts\Commissions;
use WCV_Payouts\PayoutBuilder;
use WCV_Payouts\Payouts;
/**
* Triggers a payout for all order commissions when an order is marked
* complete.
*
@bporcelli
bporcelli / ms-force-overnight-shipping.php
Created October 2, 2021 17:32
[MarketShip] Partially complete code for forcing 1 or 2 day shipping for shipments with perishable items. TODOs need to be completed.
<?php
/**
* Force use of 1 day shipping if vendor shipping package includes
* perishable items.
*
* @param array $rates Shipping package rates.
* @param array $package Shipping package.
*
* @return array
@bporcelli
bporcelli / keybase.md
Created September 27, 2021 20:19
Keybase authentication

Keybase proof

I hereby claim:

  • I am bporcelli on github.
  • I am bporcelli (https://keybase.io/bporcelli) on keybase.
  • I have a public key ASA0TWkOn7xTTkrVcprgiz_Q58ajvl59T_BZyeOEW-EqTgo

To claim this, I am signing this object:

@bporcelli
bporcelli / ms-hide-1-day-services.php
Created September 15, 2021 01:58
[MarketShip] Hide 1 day shipping services.
<?php
/**
* Hides all shipping services with an estimated delivery time of 1 day.
*
* @param bool $show_rate Whether to show the shipping rate.
* @param array $rate Shippo Rate object.
*
* @return bool
*/
@bporcelli
bporcelli / ms-disable-shipping-services.php
Last active September 15, 2021 01:53
Shows how to disable selected shipping services in MarketShip.
<?php
/**
* Returns a list of Shippo shipping services to disable.
*
* @return string[]
*/
function ms_get_disabled_shipping_services() {
// List shipping services to disable here.
// See https://goshippo.com/docs/reference#servicelevels for possible values.
@bporcelli
bporcelli / wc-hide-all-shipping-if-free-shipping-is-available.php
Last active August 5, 2021 00:45 — forked from woogists/wc-hide-all-shipping-if-free-shipping-is-available.php
[General Snippets][Hide other shipping methods when “Free Shipping” is available] Hides all other shipping methods but free_shipping if it’s available. Compatible with Shipping zones.
/**
* Hide shipping rates when free shipping is available.
*
* @param array $rates Array of rates found for the package.
* @return array
*/
function my_hide_shipping_when_free_is_available( $rates ) {
$free = array();
foreach ( $rates as $rate_id => $rate ) {
if ( 0 === (int) $rate->cost ) {
@bporcelli
bporcelli / ms-set-default-shipping-methods.php
Last active June 17, 2022 12:35
[MarketShip] Set default shipping methods
<?php
/**
* Changes which shipping methods are enabled by default for MarketShip.
*
* @param array $shipping_methods Shipping methods enabled for vendor.
* @param int $vendor_id Vendor user ID.
*
* @return array
*/
@bporcelli
bporcelli / trs-check-for-free-shipping.php
Last active April 28, 2021 03:00
Check whether vendors offer free shipping with TRS
<?php
/**
* Check whether a vendor offers free shipping to a country with TRS.
* This doesn't check whether free shipping would actually be available
* for a given product weight/quantity/subtotal. For that, see the
* function below.
*
* @param int $vendor_id Vendor ID.
* @param string $country_code ISO country code.
@bporcelli
bporcelli / wc-change-eu-countries.php
Last active April 14, 2021 02:29
Customize WooCommerce Europe continent to only include EU countries
<?php
/**
* Change the "Europe" continent in WooCommerce to only include the EU countries.
*
* @param array $continents WooCommerce continents.
*
* @return array
*/
function pluginpros_change_countries_for_europe( $continents ) {
@bporcelli
bporcelli / trs-hide-vendor-settings-tab.php
Created December 12, 2020 20:15
Hide the Shipping settings tab added by Table Rate Shipping in the WCV dashboard
<?php
/**
* Removes the Setings > Shipping tab in the vendor dashboard.
*
* @param array $tabs Vendor settings tabs.
*
* @return array
*/
function wcv_remove_vendor_shipping_settings_tab( $tabs ) {