Add woocommerce product review from custom template












1














I want to add the reviews of the product in woo commerce from a custom modal popup so is there a way that I can add those review into the woo commerce product.










share|improve this question






















  • Possible duplicate of Add a product review with ratings programmatically in Woocommerce
    – Jamie_D
    Nov 20 at 14:51










  • No it is not duplicated as I need to get the data from the custom form However I will try if I can get something from the above link @Jamie_D
    – Developer
    Nov 21 at 7:42
















1














I want to add the reviews of the product in woo commerce from a custom modal popup so is there a way that I can add those review into the woo commerce product.










share|improve this question






















  • Possible duplicate of Add a product review with ratings programmatically in Woocommerce
    – Jamie_D
    Nov 20 at 14:51










  • No it is not duplicated as I need to get the data from the custom form However I will try if I can get something from the above link @Jamie_D
    – Developer
    Nov 21 at 7:42














1












1








1







I want to add the reviews of the product in woo commerce from a custom modal popup so is there a way that I can add those review into the woo commerce product.










share|improve this question













I want to add the reviews of the product in woo commerce from a custom modal popup so is there a way that I can add those review into the woo commerce product.







wordpress






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 at 13:45









Developer

173




173












  • Possible duplicate of Add a product review with ratings programmatically in Woocommerce
    – Jamie_D
    Nov 20 at 14:51










  • No it is not duplicated as I need to get the data from the custom form However I will try if I can get something from the above link @Jamie_D
    – Developer
    Nov 21 at 7:42


















  • Possible duplicate of Add a product review with ratings programmatically in Woocommerce
    – Jamie_D
    Nov 20 at 14:51










  • No it is not duplicated as I need to get the data from the custom form However I will try if I can get something from the above link @Jamie_D
    – Developer
    Nov 21 at 7:42
















Possible duplicate of Add a product review with ratings programmatically in Woocommerce
– Jamie_D
Nov 20 at 14:51




Possible duplicate of Add a product review with ratings programmatically in Woocommerce
– Jamie_D
Nov 20 at 14:51












No it is not duplicated as I need to get the data from the custom form However I will try if I can get something from the above link @Jamie_D
– Developer
Nov 21 at 7:42




No it is not duplicated as I need to get the data from the custom form However I will try if I can get something from the above link @Jamie_D
– Developer
Nov 21 at 7:42












2 Answers
2






active

oldest

votes


















0














See the last entry by @Maha Dev on this post ...



Example:



global $product;
$p_id = $product->get_id();

$comment_and_reviews = $wpdb->get_results("SELECT wpc.comment_author,wpc.comment_author_email,wpc.comment_date,wpc.comment_content,wpcm.meta_value AS rating FROM `" . $wpdb->prefix . "comments` AS wpc INNER JOIN `" . $wpdb->prefix . "commentmeta` AS wpcm ON wpcm.comment_id = wpc.comment_id AND wpcm.meta_key = 'rating' WHERE wpc.comment_post_id = '" . $p_id . "' ");
print_r($comment_and_reviews);
exit();





share|improve this answer





















  • This helps in displaying I need to add this from frontend
    – Developer
    Nov 21 at 10:13










  • You can use this code in a template or a template part. If your modal is not either, your need to load WordPress in your modal: require('/path/to/wp-load.php'); I do suggest making your modal a template part
    – Jamie_D
    Nov 21 at 10:24





















0














You may please add the following code to add review into your woocommerce product



<?php
require('../../../../wp-config.php');
global $wpdb;
$data = array(
'comment_post_ID' => 1,
'comment_author' => 'admin',
'comment_author_email' =>'admin@example.com',
'comment_author_url' => 'http://example.com',
'comment_content' => 'My review',
'comment_type' => '',
'comment_parent' => 0,
'user_id' => 1,
'comment_approved' => 1,
);

wp_insert_comment($data);


Do let me know if you still face any issue into this






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53394409%2fadd-woocommerce-product-review-from-custom-template%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    See the last entry by @Maha Dev on this post ...



    Example:



    global $product;
    $p_id = $product->get_id();

    $comment_and_reviews = $wpdb->get_results("SELECT wpc.comment_author,wpc.comment_author_email,wpc.comment_date,wpc.comment_content,wpcm.meta_value AS rating FROM `" . $wpdb->prefix . "comments` AS wpc INNER JOIN `" . $wpdb->prefix . "commentmeta` AS wpcm ON wpcm.comment_id = wpc.comment_id AND wpcm.meta_key = 'rating' WHERE wpc.comment_post_id = '" . $p_id . "' ");
    print_r($comment_and_reviews);
    exit();





    share|improve this answer





















    • This helps in displaying I need to add this from frontend
      – Developer
      Nov 21 at 10:13










    • You can use this code in a template or a template part. If your modal is not either, your need to load WordPress in your modal: require('/path/to/wp-load.php'); I do suggest making your modal a template part
      – Jamie_D
      Nov 21 at 10:24


















    0














    See the last entry by @Maha Dev on this post ...



    Example:



    global $product;
    $p_id = $product->get_id();

    $comment_and_reviews = $wpdb->get_results("SELECT wpc.comment_author,wpc.comment_author_email,wpc.comment_date,wpc.comment_content,wpcm.meta_value AS rating FROM `" . $wpdb->prefix . "comments` AS wpc INNER JOIN `" . $wpdb->prefix . "commentmeta` AS wpcm ON wpcm.comment_id = wpc.comment_id AND wpcm.meta_key = 'rating' WHERE wpc.comment_post_id = '" . $p_id . "' ");
    print_r($comment_and_reviews);
    exit();





    share|improve this answer





















    • This helps in displaying I need to add this from frontend
      – Developer
      Nov 21 at 10:13










    • You can use this code in a template or a template part. If your modal is not either, your need to load WordPress in your modal: require('/path/to/wp-load.php'); I do suggest making your modal a template part
      – Jamie_D
      Nov 21 at 10:24
















    0












    0








    0






    See the last entry by @Maha Dev on this post ...



    Example:



    global $product;
    $p_id = $product->get_id();

    $comment_and_reviews = $wpdb->get_results("SELECT wpc.comment_author,wpc.comment_author_email,wpc.comment_date,wpc.comment_content,wpcm.meta_value AS rating FROM `" . $wpdb->prefix . "comments` AS wpc INNER JOIN `" . $wpdb->prefix . "commentmeta` AS wpcm ON wpcm.comment_id = wpc.comment_id AND wpcm.meta_key = 'rating' WHERE wpc.comment_post_id = '" . $p_id . "' ");
    print_r($comment_and_reviews);
    exit();





    share|improve this answer












    See the last entry by @Maha Dev on this post ...



    Example:



    global $product;
    $p_id = $product->get_id();

    $comment_and_reviews = $wpdb->get_results("SELECT wpc.comment_author,wpc.comment_author_email,wpc.comment_date,wpc.comment_content,wpcm.meta_value AS rating FROM `" . $wpdb->prefix . "comments` AS wpc INNER JOIN `" . $wpdb->prefix . "commentmeta` AS wpcm ON wpcm.comment_id = wpc.comment_id AND wpcm.meta_key = 'rating' WHERE wpc.comment_post_id = '" . $p_id . "' ");
    print_r($comment_and_reviews);
    exit();






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 21 at 9:00









    Jamie_D

    49438




    49438












    • This helps in displaying I need to add this from frontend
      – Developer
      Nov 21 at 10:13










    • You can use this code in a template or a template part. If your modal is not either, your need to load WordPress in your modal: require('/path/to/wp-load.php'); I do suggest making your modal a template part
      – Jamie_D
      Nov 21 at 10:24




















    • This helps in displaying I need to add this from frontend
      – Developer
      Nov 21 at 10:13










    • You can use this code in a template or a template part. If your modal is not either, your need to load WordPress in your modal: require('/path/to/wp-load.php'); I do suggest making your modal a template part
      – Jamie_D
      Nov 21 at 10:24


















    This helps in displaying I need to add this from frontend
    – Developer
    Nov 21 at 10:13




    This helps in displaying I need to add this from frontend
    – Developer
    Nov 21 at 10:13












    You can use this code in a template or a template part. If your modal is not either, your need to load WordPress in your modal: require('/path/to/wp-load.php'); I do suggest making your modal a template part
    – Jamie_D
    Nov 21 at 10:24






    You can use this code in a template or a template part. If your modal is not either, your need to load WordPress in your modal: require('/path/to/wp-load.php'); I do suggest making your modal a template part
    – Jamie_D
    Nov 21 at 10:24















    0














    You may please add the following code to add review into your woocommerce product



    <?php
    require('../../../../wp-config.php');
    global $wpdb;
    $data = array(
    'comment_post_ID' => 1,
    'comment_author' => 'admin',
    'comment_author_email' =>'admin@example.com',
    'comment_author_url' => 'http://example.com',
    'comment_content' => 'My review',
    'comment_type' => '',
    'comment_parent' => 0,
    'user_id' => 1,
    'comment_approved' => 1,
    );

    wp_insert_comment($data);


    Do let me know if you still face any issue into this






    share|improve this answer


























      0














      You may please add the following code to add review into your woocommerce product



      <?php
      require('../../../../wp-config.php');
      global $wpdb;
      $data = array(
      'comment_post_ID' => 1,
      'comment_author' => 'admin',
      'comment_author_email' =>'admin@example.com',
      'comment_author_url' => 'http://example.com',
      'comment_content' => 'My review',
      'comment_type' => '',
      'comment_parent' => 0,
      'user_id' => 1,
      'comment_approved' => 1,
      );

      wp_insert_comment($data);


      Do let me know if you still face any issue into this






      share|improve this answer
























        0












        0








        0






        You may please add the following code to add review into your woocommerce product



        <?php
        require('../../../../wp-config.php');
        global $wpdb;
        $data = array(
        'comment_post_ID' => 1,
        'comment_author' => 'admin',
        'comment_author_email' =>'admin@example.com',
        'comment_author_url' => 'http://example.com',
        'comment_content' => 'My review',
        'comment_type' => '',
        'comment_parent' => 0,
        'user_id' => 1,
        'comment_approved' => 1,
        );

        wp_insert_comment($data);


        Do let me know if you still face any issue into this






        share|improve this answer












        You may please add the following code to add review into your woocommerce product



        <?php
        require('../../../../wp-config.php');
        global $wpdb;
        $data = array(
        'comment_post_ID' => 1,
        'comment_author' => 'admin',
        'comment_author_email' =>'admin@example.com',
        'comment_author_url' => 'http://example.com',
        'comment_content' => 'My review',
        'comment_type' => '',
        'comment_parent' => 0,
        'user_id' => 1,
        'comment_approved' => 1,
        );

        wp_insert_comment($data);


        Do let me know if you still face any issue into this







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 22 at 5:24









        Pratik bhatt

        356520




        356520






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53394409%2fadd-woocommerce-product-review-from-custom-template%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Costa Masnaga

            Fotorealismo

            Sidney Franklin