1. Home
  2. Product Input Fields for WooCommerce
  3. Hooks: Actions and Filter reference

Hooks: Actions and Filter reference

The following is a list of all hooks present in the plugin. This list is intended to guide developers who are looking to extend the functionality of Product Input Fields for WooCommerce plugin.

 

This will remove the ‘form=cart’ attribute from the input fields.This filter should be used when there is theme issue where the data is not passed in the cart.

/**
* Add this code snippet in functions.php file of your currently active theme.
*/
function alg_wc_pif_remove_form_cart_attribute_callback( $form_cart_attribute ){
$form_cart_attribute = true;
return $form_cart_attribute;
}
add_filter( 'alg_wc_pif_remove_form_cart_attribute', 'alg_wc_pif_remove_form_cart_attribute_callback' );


Code for solving the compatibility issue with WooCommerce Product Addons plugin.

/**
* Add this code snippet in functions.php file of your currently active theme.
*/
function addon_alg_pif_recalculate_product_price( $alg_price, $product_price, $value ) {

foreach($value['addons'] as $addon_value ){
$price_type = $addon_value['price_type'];
if ( $addon_value['price'] && 'percentage_based' === $price_type && 0 != $product_price ) {
$addon_price = $product_price * ( $addon_value['price'] / 100 );
} else {
$addon_price = $addon_value['price'];
}
// Add WC Product Addons price in the total price calculated for PIF.
$alg_price = $alg_price + $addon_price;
}
return $alg_price;
}
add_filter( 'alg_pif_recalculate_product_price', 'addon_alg_pif_recalculate_product_price', 10, 3 );


Code for not showing the product input fields in the child products of Composite products on the cart page.

/**
* Add this code snippet in functions.php file of your currently active theme.
*/
function remove_pif_in_child_products() {
return false;
}
add_filter( 'alg_wc_pif_no_pif_in_child_products', 'remove_pif_in_child_products' );


Code for solving the pricing issue with WooCommerce Booking Plugin.

/**
* Add this code snippet in functions.php file of your currently active theme.
*/
function woo_booking_alg_pif_recalculate_product_price( $alg_price, $price, $value ) {
if ( isset( $value['booking'] ) ) {
$alg_price = ( (int) $alg_price - (int) $price ) + $value['booking']['_cost'];
}
return $alg_price;
}
add_filter( 'alg_pif_recalculate_product_price', 'woo_booking_alg_pif_recalculate_product_price', 10, 3 );


Show only image or image with name in cart and checkout page.

/**
* Show only image or image with name in cart and checkout page.
*
* @param bool $only_image default value false.
*/
function alg_wc_pif_show_only_image_callback( $only_image ) {
return true;
}
add_filter( 'alg_wc_pif_show_only_image', 'alg_wc_pif_show_only_image_callback', 99, 1 );


Added thumbnail dimensions for Show only image or image with name in cart and checkout page. 

/**

 * Added thumbnail dimensions for image in cart and checkout page.
 *
 * @param int $height int default value 64.
 * @param int $width int default value 64.
 */
function alg_wc_pif_thumbnail_dimensions_callback( $height, $width ) {
$height = 64;
$width  = 64;

return array( $height, $width );
}
add_filter( 'alg_wc_pif_thumbnail_dimensions', 'alg_wc_pif_thumbnail_dimensions_callback', 99, 2 );
Was this article helpful to you? Yes No

How can we help?