Skip to content

Instantly share code, notes, and snippets.

@tamara-m
tamara-m / import-optimizations.md
Created July 30, 2021 20:23 — forked from trey8611/import-optimizations.md
WP All Import - Optimize your import speed.
@tamara-m
tamara-m / membermouse-searches-and-hooks.php
Created July 21, 2021 20:58
Various searches in MemberMouse PHP. Various MemberMouse Hooks
/**
* Get Member IDs
*/
$member_ids = array();
$view = new MM_MembersView();
$dataGrid = new MM_DataGrid(null, null, "desc", 99999);
$data = $view->search(null, $dataGrid);
foreach ( $data as $member ) {
$member_ids[] = $member->id;
<?php
/**
* Create multiple variables for calculation fields
*/
function prefix_calculation_global_calculation_vars( $vars ) {
return array(
'my_first_variable' => 50,
'price_modifier_1' => 150
);
}
<?php
/**
* Return a blank instead of the product for products that contain child products
*/
function my_prefix_cart_item_price( $price, $cart_item, $cart_item_key ) {
$product_id = $cart_item['data']->get_id();
// Add the product IDs here that contain child products
if( in_array( $product_id, array( 5121, 2222 ) ) ) {
// You can enter different text below if you wish
return '-';
<?php
/**
* A products field template
* Ensure that the 'Products Quantities' field is set to 'One Only'
* @since 2.2.0
* @package WooCommerce Product Add Ons Ultimate
*/
// Exit if accessed directly
if( ! defined( 'ABSPATH' ) ) {
<?php
/**
* Filter the price html on shop and product pages
* @todo Display correct variation price range in variation.php
*/
function prefix_get_price_html( $price, $product ) {
$rules = get_option( 'wcfad_dynamic_pricing_rules', false );
// Get the best user role defined price
<?php
function prefix_reset_table_quantity( $args, $product ) {
$args['input_value'] = 1;
return $args;
}
add_filter( 'woocommerce_quantity_input_args', 'prefix_reset_table_quantity', 10, 2 );
<?php
/**
* Use this filter to set a different default quantity for child products
*/
function prefix_filter_default_child_independent_quantity( $quantity_field_value, $child_product_id, $item ) {
return 1;
}
add_filter( 'pewc_child_product_independent_quantity', 'prefix_filter_default_child_independent_quantity', 10, 3 );
<?php
function pewc_get_multicurrency_price( $price, $item, $product ) {
// Compatibility with WooCommerce multilingual
$price = apply_filters( 'wcml_raw_price_amount', $price );
if( class_exists('WOOCS') ) {
global $WOOCS;
if ($WOOCS->is_multiple_allowed) {
$price = $WOOCS->woocs_exchange_value( floatval( $price ) );
/**
* Load Elasticseach PHP 7 Client via composer
* Updated for ElasticPress 3.3
*/
require 'vendor/autoload.php';
/**
* Init Elasticsearch PHP Client
*/
use Elasticsearch\ClientBuilder;