Skip to content

Instantly share code, notes, and snippets.

@xadapter
xadapter / woo-download-credits-platinum.php
Created December 18, 2019 13:50
woo-credits compatibility - following functions to be modified in woo-credits plugin
//added phive_booking condition also, so that credits can be calculated according to the number of recurrences and the number of persons if "Consider each participant as separate booking" is checked.
public static function get_credit_from_cart_item($item, $single = true, $composite = false)
{
$total_credits_amount = 0;
$prod_id = wdcp_get_product_id_cart_item($item);
$prod_id = wdcp_icl_object_id($prod_id);
$product = $item['data'];
if (!$product->is_type('credits'))
@xadapter
xadapter / functions.php
Created December 18, 2019 13:45
woo-credits compatibility
// to display correct credit amount for line total and subtotal after order is placed. In case of person as booking, the credits should be multiplied with number of participants.
add_filter('woocommerce_order_subtotal_to_display', 'order_subtotal_to_display_with_credits', 11, 3);
add_filter('woocommerce_order_formatted_line_subtotal', 'order_formatted_line_subtotal_with_credits', 11, 3);
function order_subtotal_to_display_with_credits($subtotal, $compound, $order)
{
$order_id = (WC()->version < '2.7.0') ? $order->id : $order->get_id();
$credits_total = 0;
$payment_method = get_post_meta($order_id, '_payment_method', true);
@xadapter
xadapter / functions.php
Created August 29, 2018 07:38
Support for YITH Product Bundle with Product Import Export for WooCommerce by Xadapter
add_filter('woocommerce_csv_product_post_columns','woocommerce_csv_product_post_columns',1);
function woocommerce_csv_product_post_columns($default_post_columns=array()){
$default_post_columns['_yith_wcpb_bundle_data'] = 'meta:_yith_wcpb_bundle_data';
return $default_post_columns;
}
add_filter('hf_woocommerce_csv_product_import_allowed_product_types', 'hf_woocommerce_csv_product_import_allowed_product_types', 1);
@xadapter
xadapter / functions.php
Last active September 19, 2019 06:19
Snippet to change UPS account details in rate request when Access Point address has been selected. WooCommerce UPS Shipping Plugin with Print Label by PluginHive - https://www.pluginhive.com/product/woocommerce-ups-shipping-plugin-with-print-label/
/**
* Snippet to change UPS account details in rate request when Access Point address has been selected.
* Created at : 27 Aug 2018
* Updated at : 27 Aug 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/xadapter/8891ba54b0cd2a642813e83e1d7e9810
*/
if( ! function_exists('ph_change_ups_account_for_accesspoint_rate_request') ) {
function ph_change_ups_account_for_accesspoint_rate_request( $xml_request, $package ){
@xadapter
xadapter / function.php
Last active September 19, 2019 06:45
Snippet to change Estimated Delivery date style on cart page using Estimated Delivery Date Plugin for WooCommerce by PluginHive - https://www.pluginhive.com/product/estimated-delivery-date-plugin-woocommerce/
/**
* Snippet to change Estimated Delivery date style on cart page.
* Created at : 24 Aug 2018
* Updated at : 24 Aug 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/xadapter/23dc533d6e166b76fa25d0c8d4fd0f5b
*/
add_filter( 'xa_estimated_delivery_cart_checkout_page_html_formatted_date', function($date) {
$date = str_replace( '<td', '<td style="font-weight: bold;"', $date);
@xadapter
xadapter / functions.php
Last active September 19, 2019 06:47
Snippet to change UPS credentials in UPS Access-point Locator Request using WooCommerce UPS Shipping Plugin with Print Label by PluginHive - https://www.pluginhive.com/product/woocommerce-ups-shipping-plugin-with-print-label/
/**
* Snippet to change UPS credentials in UPS Accesspoint Locator Request. Requires UPS plugin version - 3.10.2.
* Created at : 22 Aug 2018
* Updated at : 22 Aug 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/xadapter/cb7a9a83b11d953077c57e4bcc8fa072
*/
if( ! function_exists('ph_change_ups_accesspoint_credentials') ){
function ph_change_ups_accesspoint_credentials( $xml_request, $ups_settings ) {
@xadapter
xadapter / functions.php
Created August 17, 2018 11:21
Import / Export bundle products using XAdapter Product Import Export for WooCommerce plugin - - with SKU
add_filter('hf_insert_post_extra_data', 'hf_import_alter_product_csv_row_data', 100, 3);
add_action('hf_alter_product_export_csv_columns', 'hf_alter_product_csv_columns_head', 100);
add_action('hf_alter_product_export_csv_data', 'hf_alter_product_csv_row_data', 100, 2);
/**
Product bundle export/import code snippet - with SKU
@global type $wpdb
@param type $additional_columns
@return array
@xadapter
xadapter / functions.php
Last active September 19, 2019 06:47
Snippet to change weight in Woocommerce Canada Post Rate Request. WooCommerce Canada Post Shipping Plugin with Print Label - https://www.pluginhive.com/product/woocommerce-canada-post-shipping-plugin-with-print-label/
/**
* Snippet to change weight in Woocommerce Canada Post Rate Request.
* Created at : 10 Aug 2018
* Updated at : 10 Aug 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/xadapter/f6c84df50af11b5f952e170379933f7f
*/
add_filter( 'xa_canadapost_rate_request', function( $request ){
$default_weight = 15; // In kg
/**
* Snippet to hide duplicate shipping rates (Name and Cost both should match).
* Created at : 09 Aug 2018
* Updated at : 09 Aug 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/xadapter/71473722eb88105bf70d6d5d0932aed1
*/
add_filter( 'woocommerce_package_rates', function( $shipping_rates ){
$hide_duplicate_rules = array('wf_multi_carrier_shipping'); // Hide Duplicate Rates for these shipping methods
/**
* Snippet to add handling charge to WooCommerce Shipping Methods based on Shipping Class.
* Created at : 06 Aug 2018
* Updated at : 06 Aug 2018
* PluginHive Plugins : https://www.pluginhive.com/plugins/
* Gist Link : https://gist.github.com/xadapter/288aff384db2a04fb3b96ec53239dbc0
*/
add_filter( 'woocommerce_package_rates', 'ph_add_extra_cost_based_on_shipping_class', 10, 2);
if( ! function_exists('ph_add_extra_cost_based_on_shipping_class') ) {