How to create a custom "add to cart" button in woocomerce [closed] - wordpress

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Good morning
I am trying to create a custom add to cart button that only works when the customer answers a question correctly.

if ( /* Your condition ... */ ) {
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woocommerce_custom_single_add_to_cart_text' );
function woocommerce_custom_single_add_to_cart_text() {
return __( 'Your text...', 'woocommerce' );
}
}

Related

Hello I can’t make js files in the bottom in Wordpress [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 months ago.
Improve this question
function med_scripts() {
wp_enqueue_script('BOOT-js', get_template_directory_uri() . '/assets/js/main.js', array(), "0.1", true);
}
add_action('wp_enqueue_scripts','med_scripts');
Your code is working correctly. I tested it on my development site. You need to create a main.js file in the js folder if main.js does not exist. If you write custom code for jQuery, please pass jquery in the array. for example:
function med_scripts() {
wp_enqueue_script('BOOT-js', get_template_directory_uri() . '/assets/js/main.js', array( 'jquery' ), "0.1", true);
}
add_action('wp_enqueue_scripts','med_scripts');
Screenshot

Change status of add to cart button depends on quantity Woocommerce [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
on woocommerce site I would like when the product has 0 qty to show the add to cart button disabled and not disappeared.
https://woocommerce.github.io/code-reference/classes/WC-Product.html#method_get_stock_quantity
You can use the get_stock_quantity method of WC_Product to check the available count of your product.
global $product;
if ( $product && $product->get_stock_quantity() > 0 ) {
// your current button
} else {
// disabled button
}
For loop, you can use the hooks from this template and for a single page from these.

Wordpress Woocommerce shop page [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I need help adding VIEW and ADD button into my Woocommerce Shop page. Do you have any plugins or codes that I can add into my functions.php?
You can try this code to add add to cart and view button in shop page
//// to add cart buttton
function add_cart_to_shop () {
add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_add_to_cart', 10 );
}
add_action( 'after_setup_theme', 'add_cart_to_shop' );
//// to add view buttton
function add_view_to_shop() {
echo 'View';
}
add_action( 'woocommerce_after_shop_loop_item', 'add_view_to_shop', 8 );
Try this then let me know the result.
You need css code to design it yourself.
Thanks

How to create custom post type item by submitting form on frontend in Wordpress [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have a form in my Wordpress theme and I want to create custom post when I submit that form and to fill that custom post with some data from the form. What would it be? A plugin or maybe just several strings of code in functions.php? Kindly show me proper directions.
Please go to this link "insert post from frontend"
Hope the above tutorial will full fill your requirement also you can use "frontier-post" plugin to do your task.
Easiest way to do it is create a Page Template with the code to capture the form's post data. You'll also need wp_insert_post.
<?php
/**
* Template Name: My Custom Form Page
**/
?>
<?php
if(isset($_POST['my_form'])):
// do something with the data
$post = array();
$post['post_title'] = $_POST['user_title'];
$post['post_content'] = $_POST['user_content']);
$post['post_type'] = 'my_custom_post_type';
$postID = wp_insert_post($post);
endif;
// continue to template with form
?>

Change email address from Wordpress sites [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I have a Wordpress site with front end login, it has the password recovery link which works fine.
The problem I have is that the password reset email that the user gets is saying it's from:
WordPress <wordpress#domain.com>
Is there a way I can change this? Possibly remove the word wordpress and/or change the actual email address it's from?
You can this data in the wp-admin panel, General tab. Change the email adress and the domain name.
It should works.
If it's not working, consider using the Send From plugin or add some filter to 'wp_mail_from' like
function use_my_email(){
return 'email#domain.com';
}
add_filter( 'wp_mail_from', 'just_use_my_email' );
and 'wp_mail_from_name'
function use_my_name(){
return 'My Real Name';
}
add_filter( 'wp_mail_from_name', 'just_use_my_email_name' );

Resources