Add following code to your functions.php
file in theme directory.
add_action('init', 'set_point_earned');
function set_point_earned() {
global $wpdb;
$wpdb->query("INSERT INTO {$wpdb->postmeta} (post_id, meta_key, meta_value)
SELECT ID, '_ywpar_point_earned', '5' FROM {$wpdb->posts} WHERE post_type IN ('product','product_variation') AND NOT EXISTS ( SELECT * FROM {$wpdb->postmeta} WHERE post_id = ID AND meta_key = '_ywpar_point_earned' )");
}
Then visit your site. After applying the changes you can remove code from functoins.php
. If you want every product have a point by default keep code!
Related Posts:
- Woocommerce Add Variation Product to Cart from custom link [closed]
- How do I get WooCommerce to automatically recreate pages? [closed]
- WooCommerce – How to Add a Custom Field to Cart Items and Cart Totals [closed]
- User profiles and object associations
- how to redirect to my template
- Custom Shipping method not showing in checkout
- WP Crowdfunding customization [closed]
- Can’t create term for product attribute
- block countries from shipping to them in WooCommerce [closed]
- Is it possible to set up multistore in Woocommerce? [closed]
- How to get subscription key or id using Woocommerce Subscriptions [closed]
- WooCommerce E-Check payment gateway disappeared when site switched to multi-site
- woocommerce_order_status_completed action hook not working [closed]
- How to update billing_email when user_email is updated [closed]
- How to configure two SMTP Server for wordpress
- Woocommerce plugin for minimum order and add-to-card-step
- Add Product Subtitle to Woocommerce Product Page
- Change wordpress current_time function to different timezone
- How can you include a theme template file from within a plugin (i.e. WooCommerce’s Shop page)?
- Automatically add attributes to woocommerce product?
- What are wsm tables for?
- Woocommerce API HTTP Response 401
- How to use WP-CLI / WC-CLI to bulk import 1000s of products (variable and simple)?
- woocommerce payment gateway callback not firing [closed]
- WordPress Keeps Logging Out – What Tests Can I Run to Solve This?
- Programmatically Process Order through WooCommerce/Stripe Payment Gateway [closed]
- Change Product Addon price based on select Variation
- WooCommerce – Maximum qty per line per product
- Woocommerce Create custom product type with variations
- Remove /product/ from url. I want only category name then product name
- Filtering WooCommerce Orders by Category
- creating a custom shop page display on archive woocommerce
- Adding Static Image to WooCommerce Content-Single-Product template
- Hide a Menu Item on Login
- Show icons or badges under title on product archives/category pages
- WooCommerce: after install hook
- How to add a new column with text fields to WooCommerce Cart List?
- Woocommerce: limit user to see only the products he created
- How do I get the Payzone WooCommerce payment gateway plugin to show up in the settings? [closed]
- Error with get_price (and others) in self-written plugin to show price
- How to change WooCommece variation data programmtically [closed]
- .php file for woocommerce edit category? [closed]
- Advanced Custom Fields (acf) – Filter Relationship by Taxonomies not Post Type
- how get curent URL slug from archive page [closed]
- dynamically create callback functions inside a for loop
- How to add category and subcategory in WordPress custom code?
- Customizing $product->get_title() function
- Woocommerce checkout page broken when set as a checkout in woocommerce settings [closed]
- WordPress Phone Field Check (use numbers, spaces and pluses)
- Can export gallery but can’t import it Wp all import
- WooCommerce – I want to add functionality of one plugin to another plugin — best approach?
- Get product categories and add them to a custom taxonomy
- How to make WooCommerce payment method field optional?
- How to Get Category Name When Export Products
- wp_query ‘s’ parameter does not work with WC_AJAX
- Add Plugin broken after removing Booster for Woocommerce
- Display top level parent category as a single product body class (Woocommerce)
- add a hook of Woocommerce to a plugin but it only shows and doesn’t function properly
- How can I find related learndash course id from woocommerce product object?
- How to Fix WordPress multisite woocommerce 403 file error
- ACF Fields are not showing up on Homepage
- Adding discount functionality to the cart
- How to find the file path in WordPress?
- How to create a plugin with automatic update?
- Woocommerce Attribute price for non-variations
- Securing langugae folder
- Add a WooCommerce Product Variant with attributes programmatically
- Change Woo Custom Endpoint Titles from a Plugin
- Use Case: Multiple Shipping Methods per Order
- Woocommerce functions in custom class, avoid errors
- Coupon Codes for product discount combined with conditional free shipping
- Fetching users data from REST API
- Automatically check “Enable stock management at product level” to the existing products?
- Change hook to add_action in a plugin class
- Woocommerce categories displayed on every category and shopping page
- 504 Timeout gateway when trying to pay for an order in Woocommerce. What else can I do?
- woocommerce product search based only title
- Need woocommerce function for getting cart list with items
- WPNeo Stripe connect does not work
- Adding/ Removing actions for plugins
- Unable to sync woocommerce variations
- How to allow customers to input a text as a product variation *and* charge per character?
- Run one-time script calling plugin functions
- Unable to show 4 products in a row
- Woocommerce quick checkout form [closed]
- Woocommerce Large Variations Shows Out of Stock Items [closed]
- WooCommerce custom query and paging: Not Found error
- WooCommerce & WooCommerce Shopee Intergration
- Why does theme need woocommerce to show images / content on front page?
- how do I solve Installation failed: There has been a critical error on your website
- WooCommerce product prices not showing up correctly [closed]
- Am I allowed to resell WordPress Premium Plugins under GPL? [closed]
- woocommerce show cities state as dropdown list
- which plugin is this? [closed]
- Adding a script & php to functions.php
- how to add meta for order in woocommerce
- WooCommerce REST API aborts connection [closed]
- Product customizing quiz – quiz adding products to the cart
- Show WooCommerce products based on query parameters on redirect
- How to create different woocommerce single_product.php pages for each product? [closed]