• Resolved JS Morisset

    (@jsmoriss)


    In my tickets, I have a variety of custom fields displayed in the “Ticket Fields” widget.

    I would like to use this information to add buttons / links to perform actions based on this information. Is there a filter or action I can hook to add buttons / links to an existing widget, or add a custom widget to the ticket?

    Thanks,

    js.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Nikhil G

    (@nsgawli)

    Hello,

    You use below hook to add your html to “Ticket Field” widget
    do_action( 'wpsc_after_ticket_fields_widget', $post_id,$fields)

    To add custom widget please use below hook
    do_action( 'wpsc_after_ticket_widget', $post_id)

    Thread Starter JS Morisset

    (@jsmoriss)

    Thanks. I added a validation widget to the ticket page:

    https://screenshots.firefox.com/p0WdPgr35J2zKFSD/surniaulula.com

    Here’s the code, in case anyone else is interested. ??

    
    add_action( 'wpsc_before_ticket_widget', 'custom_show_validation_widget' );
    
    function custom_show_validation_widget( $post_id ) {
    
    	global $current_user;
    
    	if ( ! $current_user->has_cap( 'wpsc_agent' ) ) {	// Only show widget for agents.
    		return;
    	}
    
    	$url = get_post_meta( $post_id, 'wordpress-permalink-url', true );
    
    	if ( empty( $url ) ) {	// Skip if there's no url provided.
    		return;
    	}
    
    	$url_encoded = urlencode( $url );
    
    	$buttons = array(
    		'facebook'  => array(
    			'label' => __( 'Facebook Debugger', 'supportcandy' ),
    			'url'   => 'https://developers.facebook.com/tools/debug/og/object?q=' . $url_encoded,
    		),
    		'linkedin' => array(
    			'label' => __( 'LinkedIn Inspector', 'supportcandy' ),
    			'url'   => 'https://www.linkedin.com/post-inspector/inspect/' . $url_encoded,
    		),
    		'google' => array(
    			'label' => __( 'Google Testing Tool', 'supportcandy' ),
    			'url'   => 'https://search.google.com/structured-data/testing-tool/u/0/#url=' . $url_encoded,
    		),
    		'pinterest' => array(
    			'label' => __( 'Pinterest Validator', 'supportcandy' ),
    			'url'   => 'https://developers.pinterest.com/tools/url-debugger/?link=' . $url_encoded,
    		),
    		'twitter' => array(
    			'label' => __( 'Twitter Validator', 'supportcandy' ),
    			'url'   => 'https://cards-dev.twitter.com/validator',
    		),
    		'w3c' => array(
    			'label' => __( 'W3C Markup Validation', 'supportcandy' ),
    			'url'   => 'https://validator.w3.org/nu/?doc=' . $url_encoded,
    		),
    	);
    
    	$ticket_widget_name = __( 'Validation Tools', 'supportcandy' );
    
    	$wpsc_appearance_individual_ticket_page = get_option('wpsc_individual_ticket_page');
    
    	echo '<div class="row" style="';
    	echo 'background-color:' . $wpsc_appearance_individual_ticket_page[ 'wpsc_ticket_widgets_bg_color' ] . ' !important;';
    	echo 'color:' . $wpsc_appearance_individual_ticket_page[ 'wpsc_ticket_widgets_text_color' ] . ' !important;';
    	echo 'border-color:' . $wpsc_appearance_individual_ticket_page[ 'wpsc_ticket_widgets_border_color' ] . ' !important;';
    	echo '">';
    
    	echo '<h4 class="widget_header"><i class="fa fa-check-circle"></i> ' . $ticket_widget_name . '</h4>';
    	echo '<hr class="widget_devider">';
    
    	foreach ( $buttons as $btn ) {
    		echo '<button class="btn" type="button" onclick="window.open(\'' . $btn[ 'url' ] . '\', \'_blank\');" style="';
    		echo 'background-color:' . $wpsc_appearance_individual_ticket_page['wpsc_other_reply_form_btn_bg_color'] . ' !important;';
    		echo 'color:' . $wpsc_appearance_individual_ticket_page['wpsc_other_reply_form_btn_text_color'] . ' !important;';
    		echo 'border-color:' . $wpsc_appearance_individual_ticket_page['wpsc_other_reply_form_btn_border_color'] . ' !important;';
    		echo 'margin-bottom:5px;';
    		echo 'width:100%;';
    		echo '">' . $btn[ 'label' ] . '</button>';
    	}
    
    	echo '</div>';
    }
    

    js.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to add custom buttons/links to ticket widgets?’ is closed to new replies.