Finally did it. With the update of WooCommerce, which I assumed, the syntax of the set price did change. Function now looks like this:
add_action( 'woocommerce_before_calculate_totals', 'calc_ferienspiele_discount' );
function calc_ferienspiele_discount( $cart_object ) {
global $woocommerce;
$items = $woocommerce->cart->get_cart();
$x=0;
$custom_price = 140; // This will be your custome price
foreach ( $cart_object->cart_contents as $key => $value ) {
$target_product_id=$value['data']->get_sku();
for ($_i = 1; $_i <= $value['quantity']; $_i++) {
$x++;
if ( $target_product_id=='01010101' ) {
if ($x>1) {
$value['data']->set_price($custom_price);
echo 'This works and get displayed';
}
}
}
}
}
Related Posts:
- What is your best practice to execute one-time scripts?
- Why is Google Webmaster Tools telling me to update WordPress
- How to force function to run as the last one when saving the post?
- update Semiologic?
- is wpdb->replace() already sanitized?
- How should I structure a WP website project using git and updating from WP dashboard?
- WP-CLI not recognizing commercial plugin updates
- Plugin SVN & update API – how are plugins identified?
- Set custom messages for post update/save
- How can I manually upgrade translations?
- Automating the Backup Process (30+ websites)
- Update to older wordpress version from admin?
- Auto-updating WordPress from a local zip file
- Permissions to get autoupdate to work
- Git Deploying – Disabling plugin/theme installation/update on remote?
- Block updates by Server
- WordPress 5.5 AutoUpdate schedule
- How long does it take for theme / plugin automatic updates to initiate?
- Can’t preview drafts after upgrade to 4.0!
- WordPress Version 5 – Another update is currently in progress
- Why won’t my site automatically apply updates after upgrade to 3.7?
- What are the details for function argument wp_update_plugin()
- Changing plugin slug with update
- Necessary user, group and permissions for core updates
- Reverting from a newer version of WordPress to an older version
- After updating wordpress 4.5 my homepage and images not displaying
- Make page template that is just an “include” of another?
- How to notify my plugin users about new version releases?
- Show last time WordPress site was updated / modified
- How Can I setup WP CLI on Windows development machine running AMPPS?
- Good methodology for upgrading a large/complex sites?
- Upgrading themes never works
- How can the temporary update directory be changed?
- Unable to update wordpress
- WordPress not showing upgrade to latest version
- Prevent wordpress from updating language files
- Updating client websites on a regular basis
- Some wp-admin folder file deleted when WordPress upgrade
- Possible to stay on Version 4?
- Worpdress update another update is currently in progress
- Download failed cURL error 7: . Can’t update anything
- Upgrading from 3.5.2 to 3.9.1
- Updating Existed RocketTheme Theme on WordPress
- WP 5 upgrade and ALTER TABLE wp_post … post_password
- WP-CLI command to update all plugins and core fails when executed from cron
- Fresh new install or keep old version
- WordPress 3.8.1 update error
- Updating WordPress core with zero downtime – I mean zero
- Automatic updates and merging manual changes
- What file(s) in core control automatic background updates?
- How can I quickly get a system showing the “Uncaught Error: Class ‘WP_Site_Health’ not found in” up and running again?
- WordPress and plugins can’t update (“inconsistent file permissions” error)?
- Update WordPress – Another update is currently in progress
- $wpdb->replace: WHERE?
- Is there a way to schedule automatic WordPress core updates?
- How does one dismiss the ‘upgrade notice’ when managing upgrades with SVN?
- WordPress updates being blocked by proxy
- Keep getting update notifcations despite there is nothing to update
- Which directory should be writable to update wordpress?
- Why would a WordPress site go into maintenance mode without me doing anything?
- Increased memory usage after updating to wordpress 4.3
- Installing new theme on running site
- Is it safe to update from 2.6.2 to the newest version?
- How to customize and keep things up-to-date?
- Can anything go wrong if I let users change their usernames?
- Where in the backend can I get information about the current WordPress version I am using?
- A shorter way to automatically update WordPress?
- check if WordPress website has updates remotely
- Updating WP 3.9.5 without destroying my website
- After adding mo localization files to WP 3.8.1 install backend shows new update to 3.8.1
- WordPress updates
- Cannot upgrade anything in vps install (migrated wp)
- Where does wordpress gets its core and plugin updates
- I tried updating my Live wordpress site to the latest wordpress version (v4.7) and i encountered some issues
- What do WordPress auto updates include?
- How to keep cache files after plugin update?
- Update user meta array using foreach
- Can an update corrupt my installation?
- Avoid removal of a file on plugin update
- IP Address Whitelist to Allow WordPress Core Auto Updates
- How to modify last posts block without losing modification on next WP update
- Css path changed after update wordpress to new version
- Disabling forced FTP credentials for any updates
- Parent Theme update was not showing on the update page
- Auto Update A WordPress Plugin from within another WordPress Manager Plugin
- What happend if I update my website?
- How to get the date of last updated post or page and put it in the footer
- Updates page not showing formating
- How to allow theme update downloads to WordPress installs only?
- FS method direct on NGINX
- cannot update ftp credentials even when group owner has write access
- What could have changed all of the ' characters in my content to ' strings?
- update post meta front end
- WordPress Updates 3.5.2 to 3.8 Any Problem? [duplicate]
- Restoring from a Backup after Update
- Avoid loosing changes to theme
- Update to WordPress 4.9.2, but have heavily customized theme
- cURL error 28: SSL connection timeout while can download the plugin file
- WordPress recommending to downgrade instead of upgrade?
- WordPress is updating only patch version and not minor