Add woocommerce product review from custom template
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
add a comment |
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
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
add a comment |
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
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
wordpress
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
add a comment |
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
add a comment |
2 Answers
2
active
oldest
votes
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();
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
add a comment |
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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();
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
add a comment |
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();
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
add a comment |
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();
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();
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
add a comment |
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
add a comment |
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
add a comment |
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
add a comment |
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
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
answered Nov 22 at 5:24
Pratik bhatt
356520
356520
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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