function add_product_price_altering_javascript in Ubercart Discounts (Alternative) 6.2
Same name and namespace in other branches
- 7.2 product_price_alterer_field/product_price_alterer_field.module \add_product_price_altering_javascript()
Function for writing javascript to product page.
2 calls to add_product_price_altering_javascript()
- discounted_price_handler::render in product_price_alterer_field/
includes/ discounted_price_handler.inc - product_price_alterer_field_field in product_price_alterer_field/
product_price_alterer_field.module - Implementation of hook_field()
File
- product_price_alterer_field/
product_price_alterer_field.module, line 133
Code
function add_product_price_altering_javascript() {
static $product_price_alterer_field_javascript_added;
if (empty($product_price_alterer_field_javascript_added)) {
$product_price_alterer_field_javascript_added = TRUE;
//Alter price using javascript
drupal_add_js("\n \$(document).ready(function() {\n \$('.views-field-discounted-price').each(function() {\n var self = \$(this);\n var content = self.find('.field-content:first');\n if ((content.size() > 0) && (\$.trim(content.html()).length == 0)) {\n return true;\n }\n else if (\$.trim(self.html()).length == 0) {\n return true;\n }\n\n self.parent().find('.views-field-sell-price:not(th)').addClass('original-sell-price');\n });\n \$('.uc-price-sell:not(.original-sell-price), .sell-price:not(.original-sell-price)').each(function() {\n var self = \$(this);\n if (self.parents('.node').find('.field-type-discounted-price').length > 0) {\n self.addClass('original-sell-price');\n }\n });\n });", 'inline');
}
}