Created
February 18, 2024 08:08
-
-
Save geekontheroad/13d496ed6e34c27b8c7cb37d23b0da12 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // don't copy this | |
/** | |
* This is a snippet for the Gravity Live Summary Pro addon (http://geekontheroad.com/live-summary-for-gravity-forms/) | |
* | |
* It will modify the columns displayed in the live summary mergetag by modifying the underlying templates | |
* In this case it will remove the QTY and UNIT columns from the live summary mergetag | |
* | |
* By Default this code will apply to all forms but it can be limited by adding form-ids to the allowed_forms array at the top of the function. | |
* | |
* Copy the below code to your functions.php or code snippet plugin | |
***/ | |
add_filter("gotrls_mergetag_template_part_order-summary-item", "gotrls_remove_unit_and_qty_from_summary_mergetag", 10, 2); | |
add_filter("gotrls_mergetag_template_part_order-summary-head", "gotrls_remove_unit_and_qty_from_summary_mergetag", 10, 2); | |
add_filter("gotrls_mergetag_template_part_order-ecom-line", "gotrls_remove_unit_and_qty_from_summary_mergetag", 10, 2); | |
function gotrls_remove_unit_and_qty_from_summary_mergetag($template, $form_id) { | |
// add form ids in the below array to apply this code only to those forms. The code will be applied to all forms if no ids are found | |
$allowed_forms = array(); // EXAMPLE: array(1,2,3,4); | |
if( empty($allowed_forms) || in_array( $form_id , $allowed_forms) ) { | |
$hook = current_filter(); | |
$styleProvider = new GotrLiveSummary\MergeTags\StyleProvider($form_id); | |
$html = array(); | |
if (strpos($hook, 'order-summary-item') !== false) { | |
$html = array( | |
sprintf('<tr style="%s">', $styleProvider->get_styles('order-table/order-summary-item/element')), | |
sprintf('<td style="%s">{label} <ul class="options" style="display:none;"></ul></td>', $styleProvider->get_styles('order-table/order-summary-item/product')), | |
sprintf('<td style="%s">{price}</td>', $styleProvider->get_styles('order-table/order-summary-item/price')), | |
'</tr>' | |
); | |
} elseif (strpos($hook, 'order-summary-head') !== false) { | |
$html = array( | |
sprintf('<thead style="%s">', $styleProvider->get_styles('order-table/thead/element')), | |
sprintf('<th style="%s">%s</th>', $styleProvider->get_styles('order-table/thead/th/product'), GotrLiveSummary\MergeTags\defaultLabels::get_label('product_column_head')), | |
sprintf('<th style="%s">%s</th>', $styleProvider->get_styles('order-table/thead/th/price'), GotrLiveSummary\MergeTags\defaultLabels::get_label('price_column_head')), | |
'</thead>' | |
); | |
} elseif (strpos($hook, 'order-ecom-line') !== false) { | |
$html = array( | |
sprintf('<tr style="%s">', $styleProvider->get_styles('order-table/order-summary-item/element')), | |
sprintf('<td style="%s">{label}</td>', $styleProvider->get_styles('order-table/order-summary-item/unit')), | |
sprintf('<td style="%s">{price}</td>', $styleProvider->get_styles('order-table/order-summary-item/price')), | |
'</tr>' | |
); | |
} | |
return implode("", $html); | |
} | |
return $template; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment