Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 ) {
@bporcelli
bporcelli / trs-table-list-template-override.php
Created March 7, 2022 13:33
[Table Rate Shipping] Adds support to override the shipping table list template by copying it to a theme
<?php
/**
* Makes it possible to override the TRS table list template by copying
* it to `table-rate-shipping/shipping-table-list.php` in a theme.
*
* @param string $template_path Path to TRS table list template.
*
* @return string Template path.
*/
@bporcelli
bporcelli / shipping-method-settings.php
Created February 17, 2022 13:50
[MarketShip] Change free shipping help text with template override
<?php
/**
* Shipping method settings template.
*
* Overridden to output custom help text for Free Shipping.
*
* @global MarketShip_Shipping_Method $shipping_method Shipping method instance.
*
* @author Brett Porcelli <brett@thepluginpros.com>
* @package MarketShip
@bporcelli
bporcelli / ms-change-free-shipping-help-text.php
Created February 17, 2022 13:46
[MarketShip] Change free shipping help text
<?php
/**
* Changes the help text for Free Shipping.
* This is displayed in the Dokan dashboard at the top of the method
* settings page.
*/
function marketship_change_free_shipping_help_text() {
return __( 'My free shipping help text' );
}