Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author g5theme

    (@g5theme)

    Thanks for your questions.
    This plugin apply for book products only, so you just choose use or not.
    Can’t decide on each product.

    hi 45theme, your plugin is great,
    but i want to change the ‘look inside text to something new
    and i want that when i click on product image the book will open a pdf, how i can do that?

    I’ve done a simple modification to allow you to enable/disable this on single products.

    Happy to share the changes if anyone is still looking.

    Hi @talus

    I’m interested. Could you share your changes?

    Thank you!

    Hi again,

    No one solved this problem?

    Still looking for help.

    Thank you!

    Sorry folks, it’s been a while and I’m on other projects.

    It looks like I did 2 things. Basically, you tag Books with a checkbox and then check that when outputting the product template.

    In admin.class.php ADD a new function that outputs a checkbox to allow you to tag Books.

    		public function add_book_checkbox(){
    			woocommerce_wp_checkbox( array(
    				'id' 		=> '_enable_book_preview',
    				'label' 	=> __( 'Enable book preview', 'bpfw' ),
    			) );
    
    		}

    And then also my inc/functions.php is:

    add_filter('wc_get_template', 'bpfw_change_template_product_image', 10, 2);
    function bpfw_change_template_product_image($template, $template_name)
    {
        if ($template_name === 'single-product/product-image.php') {
            global $product;
    
            if( 'yes' == get_post_meta( $product->get_id(), '_enable_book_preview', true ) ){
                return BPFW()->locate_template('product-image.php');
            }
        }
        return $template;
    }
    
    add_action('save_post', 'bpfw_save');
    function bpfw_save($post_id)
    {
        $book_preview = 'no';
        if (!isset($_POST['bpfw_back_image_nonce']) || !wp_verify_nonce($_POST['bpfw_back_image_nonce'], 'bpfw_back_image_save')) {
            return;
        }
        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
            return $post_id;
    
        update_post_meta($post_id, 'bpfw_back_img', sanitize_text_field($_POST['bpfw_back_img']));
    
        if( isset($_POST['_enable_book_preview']) ){
            $book_preview = $_POST['_enable_book_preview'];
        }
        update_post_meta($post_id, '_enable_book_preview', $book_preview);
    
        return $post_id;
    }
    
    add_action('wp_footer', 'bpfw_add_svg_icons', 9999);
    function bpfw_add_svg_icons() {
    	BPFW()->load_file(BPFW()->plugin_dir('templates/svg-icons.php'));
    }
    jotajzam

    (@jotajzam)

    @talus thanks for the support and this amazing plugin, in mi case or theme (ASTRA PRO) if i put the codes, my site broken.

    grafica.villcom

    (@graficavillcom)

    Hi @talus, Thanks for sharing.

    I will try but this is not exactly what I was searching for (and I’m not very good with coding).

    We sell books but we have only a different category of stuff (stationery, games,for example). I wish to disable the plugin only for single product or one category.

    Let me review my code – It’s possible that I missed something @jotajzam. It’s been several months. I may just link the whole plugin.

    Any update about the code?
    I tried to modify the code as specified above, but it crashed the site.

    @eimablank
    I happen exactly the same when using the code. The site crashed

    Adrian2011

    (@adrianpetcu2011)

    It won’t crash if the snippets are placed in the right place: first in wp-content/plugins/book-previewer-for-woocommerce/inc/admin.class.php and the second in wp-content/plugins/book-previewer-for-woocommerce/inc/functions.php, and NOT in the functions.php file from the theme folder.
    But for me, in Martfury theme + wcfm plugin active, does not work (there is no checkbox to activate or de-activate 3D view after the code is inserted and the view of the gallery is the standard one.
    Big Thank you, @talus, for your idea and code.

    • This reply was modified 2 years, 11 months ago by Adrian2011.
    • This reply was modified 2 years, 11 months ago by Adrian2011.

    The top part of the code @talus offered (thank you VERY MUCH!!) can be wrapped and put in your theme’s/child theme’s functions.php (instead of in admin.class.php in the plugin’s files) like this:

    add_action( 'woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields' );
    function woo_add_custom_general_fields() {
      global $woocommerce, $post;
      echo '<div class="options_group">';
      woocommerce_wp_checkbox( array(
            'id' => '_enable_book_preview',
            'label' => __( 'Enable book preview', 'bpfw' ),
            )
        );
      echo '</div>';
    }

    Then the bottom section can replace all the code in the wp-content/plugins/book-previewer-for-woocommerce/inc/functions.php file (after the <?php).

    Doing this worked for me.

    • This reply was modified 2 years, 11 months ago by dleigh.
Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Disable for other products?’ is closed to new replies.