permission issue for product author in woocommerce - plugins

I am using following plugin:
https://wordpress.org/plugins/woocommerce-product-faqs.
If i click on the link received through mail by product author, to answer the question.
then it is displaying following message:
“Sorry, you are not allowed to access this page.”
Is there any way we can give permission to product author to answer the question.
Do i need to use this:
function filter_woocommerce_options_prefix_answer_caps( $edit_post ) {
//.........
return $edit_post;
};
add_filter( "woocommerce_answer_caps", 'filter_woocommerce_options_prefix_answer_caps', 10, 1 );
Thanks

Related

Redirect of product URL in WooCommerce app

I want to redirect all single product page whose first link URL is "product" which will be redirected to store thank you page.
I want to keep the single products, I just want the product with the path /product/ at the beginning to redirect. Since I'm currently using a product that doesn't have /product/, I need to remove from duplicate.
For example:
domain.com/product/category/product-name
domain.com/product/product-name
move to
domain.com/shop
Based on WooCommerce: Single Product Page Redirect for Logged In Customers the following snippet should work for all your single product pages:
add_action( 'template_redirect', 'bbloomer_single_product_redirect );
function bbloomer_single_product_redirect() {
if ( ! is_product() ) return;
wp_safe_redirect( '/shop' );
exit;
}

I want to display articles using gatsby-source-facebook

I want to display the data of an article using gatsby-source-facebook.
But I don't know how to write a query.
I can't find the best query at http://localhost:8000/___graphql
I make a simple website with gatsby.js.
I want to get facebook article data (posting date and text) and display it on the site.
I installed gatsby-source-facebook for that.
And changed gatsby-config.js.
→ https://www.gatsbyjs.org/packages/gatsby-source-facebook/
//`gatsby-config.js`
plugins: [
{
resolve: `gatsby-source-facebook`,
options: {
places: [`${facebookPageID}`], // Can be either a numeric ID or the URL ID
params: {
fields: 'hours, posts { message, created_time }', // See Facebooks API to see what you can query for
},
key: process.env.FACEBOOK_GRAPH_TOKEN, // You will need to create a Facebook application and go through review in order to get an API token.
},
},
],
I don't know how to write a query, so I can't get the data. (Can not be displayed.)
For example, http://localhost:8000/___graphql
query {
site {
siteMetadata {
title
         description
}
    }
}
If you enter and execute}, the title and description of the site set in gatsby-config.js enter code here will be displayed. This is normal. So how do you write a query to display facebook article data?
I searched a lot to solve this problem, but I didn't find a solution.
I only found a similar question (How to add facebook comment plugin in Gatsby?) but it could not be resolved. This question was the same as what I wrote here (https://www.gatsbyjs.org/packages/gatsby-source-facebook/).
tl;dr:
Try this:
query {
allFacebookArticles {
edges {
node {
title,
description
}
}
}
}
Explanation
That plugin stores its data into types matching the format Facebook${type} where $type is the type of thing you're pulling (in your case, articles, so it'd be FacebookArticle).
From GraphiQL, though, you should be able to see that on the sidebar on the left.
Here's an example from my current project (with some other options open):

Woocommerce - How can I add custom message in a specific place to Order Completed email?

I am trying to add a custom message to the woocommerce Order Completed Email. I would like to add a this thank you note at the beginning of the email:
"Your feedback is very important to us in order to provide you with the best quality service. So don't forget to leave a comment about how well did we do."
I tried to edit PHP templates but with no good result.
You can place this code in functions.php file of your theme:
function action_woocommerce_email_before_order_table( $order, $int, $int ) {
if($order->get_status() == 'completed') {
_e("Your custom text goes here");
}
};
add_action( 'woocommerce_email_before_order_table', 'action_woocommerce_email_before_order_table', 10, 3 );
It will also be translatable as a string.

GravityForm email address layout

Case: When a user submits a (Gravity)form and the email is received. Under the address section there is a Map It link, which links to the google maps to the specified address.
Question: How to show this link just for specific forms. It should be something like
if( $form['id'] == '101' ) {
}
But im struggling implementing this. The Map It code is defined in /wp-content/plugins/gravityforms/includes/fieldsclass-gf-field-address.php file. Line 905 //adding map link .
Thank you.
Direct add your link in "notification" area ...

How do I connect to external API from Magento

I am looking for some assistance in creating an API based module to push customer information out of Magento into a Third party loyalty program.
So far I have created a basic module but cannot find any good information on creating API based modules in Magento and could really do with some advice please...
I need to somehow hook into the Checkout success page in Magneto and add a form the will POST the customers information (name, address etc) to a third party loyalty program. I also need to be able to login to complete the billing information etc...
Does anyone know of any handy tutorials or documentation for such an implementation?
So far I have setup an API user with the appropriate roles. I have also created a very basic module for test purpses but browsing to the file I get a 404 error
apitest.php
<?php
$proxy = new SoapClient('http://mysite.com/api/?wsdl'); //edit the address and put the url to your magento here
$sessionId = $proxy->login('######', '#######'); // put in the info for your user here
echo "Login ID : $sessionId";
$result = $proxy->call($sessionId, 'Mymodule.testConnection', array('param1' => ' This string was sent from soap client'));
echo $result;
Objectmodel/api.php
<?php
class MyModule_MyModule_Model_ObjectModel_Api extends Mage_Api_Model_Resource_Abstract
{
public function testConnection($arg)
{
return "Hello World! My argument is : " . $arg;
}
}
I followed the example from here for getting a basic 'Hello world' module up and running if anyone could assist me with getting the correct setup I would be grateful
Instead of connect magento API you can create customer like this.
define('INCLUDE_PATH', '/var/www/QA/mojostage/app/');
define('INCLUDE_FILE', 'Mage.php');
Mage::app();
$customer = Mage::getModel('customer/customer');
$customer->setWebsiteId($wesite_id);
$customer->loadByEmail($customer_email);
/*
* Check if the email exist on the system.
* If YES, it will not create a user account.
*/
if (!$customer->getId()) {
//setting data such as email, firstname, lastname, and password
$customer->setEmail($customer_email);
$customer->setTaxvat($value['cus_vatnumber'])
->setCreatedAt($date1)
->setDob($value['date_of_birth'])
->setGroupId($cus_group_id)
->setConfirmation($is_active)
->setCreatedIn('Admin')
->setStoreId($store_id)
->setWebsiteId($wesite_id)
->setEntityId($value['cus_id']);
$customer->setFirstname($customer_fname);
$customer->setLastname($customer_lname);
$customer->setPassword($value['password']);
$subscriber = Mage::getModel('newsletter/subscriber');
$subscriber->setStoreId($store_id)
->setCustomerId($value['cus_id'])
->setSubscriberEmail($customer_email)
->setSubscriberStatus($value['cus_spam'])
->setSubscriberConfirmCode($subscriber->randomSequence());
}
//the save the data and send the new account email.
$customer->save();
$subscriber->save();