Advertisement
daymobrew

Add Avada button after WooCommerce product meta

Jul 13th, 2019
440
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.61 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: Add Avada button after product meta
  4. Plugin URI: https://www.damiencarbery.com
  5. Description: Add an Avada [fusion_button] after product meta. Link is to a specified category.
  6. Author: Damien Carbery
  7. Version: 0.2
  8. */
  9.  
  10. add_action( 'woocommerce_product_meta_end', 'dcwd_add_fusion_button_after_product_meta' );
  11. function dcwd_add_fusion_button_after_product_meta() {
  12.     $cat_to_text = array(
  13.         'big-bend' => 'Back to Big Bend Prints',
  14.         'grand-canyon' => 'Back to Grand Canyon Prints',
  15.         'miscellaneous' => 'Back to Miscellaneous Prints',
  16.         'plants-and-flowers' => 'Back to Plants and Flowers Gallery',
  17.         'south-padre-island' => 'Back to South Padre Island Prints',
  18.         'texas' => 'Back to Texas Prints',
  19.         'utah' => 'Back to Utah Prints',
  20.     );
  21.    
  22.     foreach ( $cat_to_text as $cat_slug => $cat_text ) {
  23.         if ( has_term( $cat_slug, 'product_cat' ) ) {
  24.             echo do_shortcode( '[fusion_button link="http://www.paulalawson.com/dev/product-category/'.$cat_slug.'/" text_transform="" title="" target="_self" link_attributes="" alignment="" modal="" hide_on_mobile="small-visibility,medium-visibility,large-visibility" class="" id="" color="default" button_gradient_top_color="" button_gradient_bottom_color="" button_gradient_top_color_hover="" button_gradient_bottom_color_hover="" accent_color="" accent_hover_color="" type="" bevel_color="" border_width="" size="" stretch="default" shape="" icon="" icon_position="left" icon_divider="no" animation_type="fade" animation_direction="left" animation_speed="0.3" animation_offset=""]'.$cat_text.'[/fusion_button]' );
  25.             return; // Return after finding one category.
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement