Skip to content

Instantly share code, notes, and snippets.

@bporcelli
bporcelli / dokan-custom-settings-tab.php
Last active October 23, 2023 15:04
Adding a custom settings tab to the Dokan vendor dashboard
<?php
/**
* NOTE: This code example uses the generic vendor prefix 'prefix_' and omits text domains where
* the WordPress internationalization functions are used. You should replace 'prefix_' with your
* own prefix and insert your text domain where appropriate when incorporating this code into your
* plugin or theme.
*/
/**
@bporcelli
bporcelli / elementor-dokan-store-button.php
Created October 11, 2023 15:12
Render an Elementor button that links to the current user's Dokan store
<?php
/**
* To create an Elementor button that links to the current user's Dokan store:
* 1) Copy/paste the code below into your child theme's `functions.php` file
* 2) Set the URL of the Elementor button to `#dokan-my-store`
*/
/**
* Filters button widgets and replaces #dokan-my-store with the
* current user's Dokan store URL.
@bporcelli
bporcelli / functions.php
Created June 23, 2023 03:09
[Simple Sales Tax] Move tax exempt form after billing details
<?php
/**
* Moves the SST Tax Exempt form to after the customer billing details.
* Place in your child theme's functions.php file or in a plugin.
*/
function sst_move_tax_exempt_form() {
global $wp_filter;
if ( ! isset( $wp_filter['woocommerce_checkout_after_customer_details'] ) ) {
@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 / marketship-remove-refunded-labels.php
Created June 17, 2022 13:01
[MarketShip] Remove refunded labels from label list
<?php
/**
* Filters the `shippo_labels` meta value to remove refunded labels.
* Workaround for label purchase limit not being increased after a
* label is refunded.
*
* @param array|string $labels Shippo labels printed for order.
*
* @return array Labels with refunded labels removed.
@bporcelli
bporcelli / marketship-enable-flat-rate-services.php
Created June 17, 2022 12:43
[MarketShip] Enable USPS flat rate services by default
<?php
/**
* Filters the default value of the marketship_shippo_usps_settings
* user meta key to enable flat rate services by default.
*
* @param mixed $value Meta value.
* @param int $user_id User ID.
* @param string $meta_key Meta key.
* @param bool $single Whether to return a single value.
@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 / marketship-set-default-boxes.php
Created March 29, 2022 12:35
[MarketShip] Set default shipping boxes for Live Rates.
<?php
/**
* Filters the default value for the `shippo_boxes` user meta key.
*
* @param mixed $value Meta value.
* @param int $user_id User ID.
* @param string $meta_key Meta key.
* @param bool $single Whether to return a single value.
*
@bporcelli
bporcelli / marketship-change-usable-box-volume.php
Created March 22, 2022 12:56
[MarketShip] Change usable box volume for packing.
<?php
/**
* Changes the usable box volume for MarketShip's packing algorithm to 100%.
*
* @param float $usable_volume Usable volume for packing.
* @param float $total_volume Total box volume.
*
* @return float Updated usable volume.
*/
@bporcelli
bporcelli / marketship-force-disable-methods.php
Created March 21, 2022 17:58
[MarketShip] Forcibly disable shipping methods.
<?php
/**
* Filters the MarketShip settings to forcibly disable some shipping methods.
*
* @param array $settings MarketShip settings.
*
* @return array
*/
function marketship_force_disable_shipping_methods( $settings ) {