• Resolved ss60

    (@ss60)


    Hi! My site is about to go public and I’m having a sudden issue. Because I’m using BOUTIQUE, a child theme of woocommerce’s storefront, they say not to add code to the theme’s template, because it won’t stay there with updates. It leads me to download a plugin called Theme Customizations to input my code snippets. I’ve been doing this and it has given me trouble in the past and has now created a critical error in my site. I’ve de-activated the plugin. I’m trying to input the following code to display my 4 custom taxonomies on the frontend of my products. This was working perfectly until it suddenly broke my site. How else can I upload this, and could there be something wrong with the code?

    Thanks so much for your help in this time sensitive manner!

    add_action( ‘woocommerce_product_meta_end’, ‘action_product_meta_end’ );
    function action_product_meta_end() {

    global $product;

    $term_ids = wp_get_post_terms( $product->get_id(), ‘author’, array(‘fields’ => ‘ids’) );

    echo get_the_term_list( $product->get_id(), ‘author’, ‘<span class=”posted_in”>’ . _n( ‘Author:’, ‘Authors:’, count( $term_ids ), ‘woocommerce’ ) . ‘ ‘, ‘, ‘, ‘</span>’ );

    global $product;

    $term_ids = wp_get_post_terms( $product->get_id(), ‘narrator’, array(‘fields’ => ‘ids’) );

    echo get_the_term_list( $product->get_id(), ‘narrator’, ‘<span class=”posted_in”>’ . _n( ‘Narrator:’, ‘Narrators:’, count( $term_ids ), ‘woocommerce’ ) . ‘ ‘, ‘, ‘, ‘</span>’ );

    global $product;

    $term_ids = wp_get_post_terms( $product->get_id(), ‘series’, array(‘fields’ => ‘ids’) );

    echo get_the_term_list( $product->get_id(), ‘series’, ‘<span class=”posted_in”>’ . _n( ‘Series:’, ‘Series:’, count( $term_ids ), ‘woocommerce’ ) . ‘ ‘, ‘, ‘, ‘</span>’ );

    global $product;

    $term_ids = wp_get_post_terms( $product->get_id(), ‘length’, array(‘fields’ => ‘ids’) );

    echo get_the_term_list( $product->get_id(), ‘length’, ‘<span class=”posted_in”>’ . _n( ‘Length:’, ‘Length:’, count( $term_ids ), ‘woocommerce’ ) . ‘ ‘, ‘, ‘, ‘</span>’ );
    }

Viewing 12 replies - 1 through 12 (of 12 total)
  • Hi,

    You could start by turning on error reporting on your website and working on those error messages.

    Debugging in WordPress

    Thread Starter ss60

    (@ss60)

    So I should purposefully make the critical error again? Where do I add the debug code?

    All information about debugging can be found in the link that I have shared.

    And in this way you can start adding custom code that is ‘update safe’.
    https://ww.wp.xz.cn/support/topic/custom-function-in-functions-php/#post-12288597

    Hello @ss60,
    You can create a custom plugin and put this custom code in that.
    Step for creating the Custom Plugin
    1-Create a PHP file in the plugins folder of your WordPress site with name custom-plugin.php
    2- Then put the following code into that all your problems will be solved through it.`<?php
    `/**
    * Plugin Name: Custom Plugin
    * Description: This woocommerce plugin customize your child theme
    * Version: 1.0.0
    * Author: Mohit Mishra
    * Author URI: https://makewebbetter.com
    * Requires at least: 3.5
    * Tested up to: 5.2.4
    * WC tested up to: 3.7.1
    * Text Domain: custom-plugin
    * Domain Path: /languages
    * License: GPL-3.0+
    * License URI: http://www.gnu.org/licenses/gpl-3.0.txt
    */

    /**
    * Exit if accessed directly
    */
    if ( ! defined( ‘ABSPATH’ ) ) {
    exit;
    }
    add_action( ‘woocommerce_product_meta_end’, ‘action_product_meta_end’ );

    function action_product_meta_end() {

    global $product;

    $term_ids = wp_get_post_terms( $product->get_id(), ‘author’, array(‘fields’ => ‘ids’) );

    echo get_the_term_list( $product->get_id(), ‘author’, ‘<span class=”posted_in”>’ . _n( ‘Author:’, ‘Authors:’, count( $term_ids ), ‘woocommerce’ ) . ”, ‘,’, ‘</span>’ );

    global $product;

    $term_ids = wp_get_post_terms( $product->get_id(), ‘narrator’, array(‘fields’ => ‘ids’) );
    echo get_the_term_list( $product->get_id(), ‘narrator’, ‘<span class=”posted_in”>’ . _n( ‘Narrator:’, ‘Narrator:’, count( $term_ids ), ‘woocommerce’ ) . ”, ‘,’, ‘</span>’ );

    global $product;

    $term_ids = wp_get_post_terms( $product->get_id(), ‘series’, array(‘fields’ => ‘ids’) );

    echo get_the_term_list( $product->get_id(), ‘series’, ‘<span class=”posted_in”>’ . _n( ‘Series:’, ‘Series:’, count( $term_ids ), ‘woocommerce’ ) . ”, ‘,’, ‘</span>’ );

    global $product;

    $term_ids = wp_get_post_terms( $product->get_id(), ‘length’, array(‘fields’ => ‘ids’) );

    echo get_the_term_list( $product->get_id(), ‘length’, ‘<span class=”posted_in”>’ . _n( ‘Length:’, ‘Length:’, count( $term_ids ), ‘woocommerce’ ) . ”, ‘,’, ‘</span>’ );
    }
    Then Save the file and go the admin section then at there you will see the cistom plugin with name “Custom Plugin” then activate this plugin all your problems will be gone through it.

    Thread Starter ss60

    (@ss60)

    Thank you!! I’m sorry, but how do I create a PHP file? I’m trying to look it up. I use WP File Manager to access everything through WP admin, but I only see an option to add TXT, CSS, or HTML. Or to upload a file.

    Sorry I don’t know how to code well!

    Thread Starter ss60

    (@ss60)

    Update: I figured out how to do it and got the plugin created, but when I tried to activate it I got this note:

    Parse error: syntax error, unexpected end of file, expecting ‘`’ in /home1/audiobq4/public_html/wp-content/plugins/custom-plugin/custom-plugin.php on line 49

    What do I do?

    Plugin Support Riaan K.

    (@riaanknoetze)

    Hi there,

    Without seeing the contents of that file, it’s hard to say for sure what’s going in. Based on the report itself, there’s a PHP coding issue on line 49 of your custom-plugin.

    Any chance you can share just that line here? Or even better, all the content of the custom-plugin/custom-plugin.php file?

    Thread Starter ss60

    (@ss60)

    Hi RK, I put in exactly what @mohitmishra posted above. Here it is again:

    <?php
    

    /**
    * Plugin Name: Custom Plugin
    * Description: This woocommerce plugin customize your child theme
    * Version: 1.0.0
    * Author: Mohit Mishra
    * Author URI: https://makewebbetter.com
    * Requires at least: 3.5
    * Tested up to: 5.2.4
    * WC tested up to: 3.7.1
    * Text Domain: custom-plugin
    * Domain Path: /languages
    * License: GPL-3.0+
    * License URI: http://www.gnu.org/licenses/gpl-3.0.txt
    */

    /**
    * Exit if accessed directly
    */
    if ( ! defined( ‘ABSPATH’ ) ) {
    exit;
    }
    add_action( ‘woocommerce_product_meta_end’, ‘action_product_meta_end’ );

    function action_product_meta_end() {

    global $product;

    $term_ids = wp_get_post_terms( $product->get_id(), ‘author’, array(‘fields’ => ‘ids’) );

    echo get_the_term_list( $product->get_id(), ‘author’, ‘<span class=”posted_in”>’ . _n( ‘Author:’, ‘Authors:’, count( $term_ids ), ‘woocommerce’ ) . ”, ‘,’, ‘</span>’ );

    global $product;

    $term_ids = wp_get_post_terms( $product->get_id(), ‘narrator’, array(‘fields’ => ‘ids’) );
    echo get_the_term_list( $product->get_id(), ‘narrator’, ‘<span class=”posted_in”>’ . _n( ‘Narrator:’, ‘Narrator:’, count( $term_ids ), ‘woocommerce’ ) . ”, ‘,’, ‘</span>’ );

    global $product;

    $term_ids = wp_get_post_terms( $product->get_id(), ‘series’, array(‘fields’ => ‘ids’) );

    echo get_the_term_list( $product->get_id(), ‘series’, ‘<span class=”posted_in”>’ . _n( ‘Series:’, ‘Series:’, count( $term_ids ), ‘woocommerce’ ) . ”, ‘,’, ‘</span>’ );

    global $product;

    $term_ids = wp_get_post_terms( $product->get_id(), ‘length’, array(‘fields’ => ‘ids’) );

    echo get_the_term_list( $product->get_id(), ‘length’, ‘<span class=”posted_in”>’ . _n( ‘Length:’, ‘Length:’, count( $term_ids ), ‘woocommerce’ ) . ”, ‘,’, ‘</span>’ );
    }
    Then Save the file and go the admin section then at there you will see the cistom plugin with name “Custom Plugin” then activate this plugin all your problems will be gone through it.

    Hello @ss60 You can download the plugin from here just click on the below link and download and install it on your website but make sure remove the previous file.
    https://bit.ly/3axjjdw

    Thread Starter ss60

    (@ss60)

    Thanks so much!!

    @ss60 Always welcome, If you any problem related to woocommerce and wordpress you can directly ping me. I am here to help you.

    We haven’t heard back from you in a while, so I’m going to mark this as resolved. Feel free to start a new thread if you have any further questions!

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘Adding code customizations to Boutique Storefront theme’ is closed to new replies.