Skip to content
This repository has been archived by the owner on Jan 15, 2020. It is now read-only.

Commit

Permalink
Prevent removal of bundle-type child subscription line items
Browse files Browse the repository at this point in the history
Does ~nothing~ to prevent removal at an application level, e.g. via a REST API call. But it's a start.
  • Loading branch information
manospsyx committed Dec 5, 2017
1 parent b1db273 commit 0f1babe
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions includes/class-wcs-att-integrations.php
Expand Up @@ -213,6 +213,10 @@ private static function add_hooks() {
// Modify bundle container cart item options to include child item prices.
add_filter( 'wcsatt_cart_item_options', array( __CLASS__, 'container_item_options' ), 10, 4 );

// Susbcription View.

// Hide "Remove" buttons of child line items under 'My Account > Subscriptions'.
add_filter( 'wcs_can_item_be_removed', array( __CLASS__, 'can_remove_child_item' ), 10, 3 );
}

/*
Expand Down Expand Up @@ -722,6 +726,24 @@ public static function container_item_options( $options, $subscription_schemes,
return $options;
}

/**
* Prevent direct removal of child subscription items from 'My Account > Subscriptions'.
* Does ~nothing~ to prevent removal at an application level, e.g. via a REST API call.
*
* @param boolean $can
* @param WC_Order_Item $item
* @param WC_Subscription $subscription
* @return boolean
*/
public static function can_remove_child_item( $can, $item, $subscription ) {

if ( self::is_bundle_type_order_item( $item ) ) {
$can = false;
}

return $can;
}

/**
* When loading bundled items, always set the active bundle scheme on the bundled objects.
*
Expand Down

0 comments on commit 0f1babe

Please sign in to comment.