Loader=$loader; \add_filter('woo_extra_products_display_total_for_cart',array($this,'TotalFormat'),10,5); \add_filter('woo_extra_products_display_switch_for_cart',array($this,'SwitchFormat'),10,5); \add_filter('woo_extra_products_display_colorpicker_for_cart',array($this,'ColorPickerFormat'),10,5); \add_filter('woo_extra_products_display_buttonselection_for_cart',array($this,'ButtonSelectionFormat'),10,5); \add_filter('woo_extra_products_display_signature_for_cart',array($this,'SignatureFormat'),10,5); \add_filter('woo_extra_products_display_colorswatcher_for_cart',array($this,'ColorSwatcherFormat'),10,5); \add_filter('woo_extra_products_display_termofservice_for_cart',array($this,'TermOfServiceFormat'),10,5); \add_filter('woo_extra_products_display_googlemaps_for_cart',array($this,'GoogleMapsFormat'),10,5); \add_filter('woo_extra_products_display_textualimage_for_cart',array($this,'TextualImageFormat'),10,5); \add_filter('woo_extra_products_display_textwithstyles_for_cart',array($this,'TextWithStyleFormat'),10,5); } public function TextWithStyleFormat($return,$value,$includeLabel=true,$field=null,$cartItemPrinter=null) { if(isset($value->Value)) return [["name"=>$value->Label, 'value'=>sanitizer::SanitizeString(wp_kses($value->Value,[])), 'field'=>'', 'key'=>$value->Label, 'display'=>Sanitizer::SanitizeHTML($value->Value)]]; return ''; } public function TextualImageFormat($return,$value,$includeLabel=true,$field=null,$cartItemPrinter=null) { return (new TextualImageFormatter($value))->Format($includeLabel); } public function GoogleMapsFormat($return,$value,$includeLabel=true,$field=null,$cartItemPrinter=null){ return (new GoogleMapsAddressFormatter($value))->Format($includeLabel); } public function TermOfServiceFormat($return,$value,$includeLabel=true,$field=null,$cartItemPrinter=null) { $display="
"; if($value->Label!=''&&$includeLabel) $display.=""; $url=''; $alt=''; if($value->Value) { $url = esc_attr($this->Loader->URL . 'images/icons/check.png'); $alt=__('Yes','additional-product-fields-for-woocommerce'); } else { $url = esc_attr($this->Loader->URL . 'images/icons/times.png'); $alt=__('No','additional-product-fields-for-woocommerce'); } $display.="$alt
"; return [array('name'=>$value->Label,'value'=>Sanitizer::GetStringValueFromPath($value,['Value']) ,'field'=>$field,'key'=>$value->Label,'display'=>$display)]; } public function ColorSwatcherFormat($return,$value,$includeLabel=true,$field=null,$cartItemPrinter=null) { $html="
"; if($includeLabel&&trim($value->Label)!='') $html.=""; $values=[]; foreach($value->SelectedValues as $currentItem) { $html.="
"; $type=''; if(isset($currentItem->Type)) $type=$currentItem->Type; $values[]=$currentItem->Color; switch ($type) { case 'text': $html.="
".esc_html($currentItem->Color)."
"; break; case 'image': $html.="
"; break; default: $html.="
"; break; } if(isset($currentItem->Value)&&$currentItem->Value!='') { $html.=''; } $html.="
"; } $html.='
'; return [array('name'=>$value->Label,'value'=>implode(', ',$values),'field'=>$field,'key'=>$value->Label,'display'=>$html)]; } public function SignatureFormat($return,$value,$includeLabel=true,$field=null,$cartItemPrinter=null) { $html="
"; if($includeLabel) $html.=""; $url=(new FileAccessManager($this->Loader))->GetDownloadURL( $value->Path, 'signature' ); $html.="
"; return [array('name'=>$value->Label,'value'=>$url,'field'=>$field,'key'=>$value->Label,'display'=>$html)]; } public function ColorPickerFormat($return,$value,$includeLabel=true,$field=null,$cartItemPrinter=null){ $html=''; $html.="
"; if($includeLabel) $html.=""; $html.="

". esc_html($value->Value) ."
"; return [array('name'=>$value->Label,'value'=>Sanitizer::GetStringValueFromPath($value,['Value']),'field'=>$field,'key'=>$value->Label,'display'=>$html)]; } public function ButtonSelectionFormat($return, $value,$includeLabel=true,$field=null,$cartItemPrinter=null){ return (new ButtonSelectionFormatter($value))->Format($includeLabel); } public function SwitchFormat($return,$value,$includeLabel=true,$field=null,$cartItemPrinter=null) { $html=''; $alt=''; if($value->Value) { $url = esc_attr($this->Loader->URL . 'images/icons/check.png'); $alt=__('Yes','additional-product-fields-for-woocommerce'); } else { $url = esc_attr($this->Loader->URL . 'images/icons/times.png'); $alt=__('No','additional-product-fields-for-woocommerce'); } $html.="
"; if($includeLabel) $html.=""; $html.="$alt
"; return [array('name'=>$value->Label,'value'=>Sanitizer::GetStringValueFromPath($value,['Value']),'field'=>$field,'key'=>$value->Label,'display'=>$html)]; } public function TotalFormat($return,$value,$includeLabel=true,$field=null,$cartItemPrinter=null) { $html=''; $alt=''; $rawValue=Sanitizer::GetStringValueFromPath($value,['Value','Value']); $html='
'.esc_html($rawValue).'
'; return [array('name'=>$value->Label,'value'=>Sanitizer::GetStringValueFromPath($value,['Value','Amount']),'field'=>$field,'key'=>$value->Label,'display'=>$html)]; } }