Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-14973

Update basket keys missing in operation_definition

    XMLWordPrintable

Details

    Description

      I am using a shop/updatebasket/before trigger to test products for available inventory against the quantity requested in the cart. Upon failure, I set the workflow to STATUS_REDIRECT_REPEAT and redirect back to the cart. If you then put a new number into the quantity field and hit the update quantities button, the system was pulling the last value you entered (instead of the new value) and allowing it through.

      For instance, if a product had inventory 10 and I tried to add 12 to my cart, it threw an error and put me back in the cart. Then I would change the requested value to 8 and re-submit, and it would put 12 items in my cart.

      I tracked this down to two issues:

      No memento keys are defined for the updatebasket function:

      kernel\shop\operation_definition.php
      line 97

      Changed to:

      'keys' => array( 'item_count_list', 'item_id_list' ),
      

      ====== Bellow is tackled in #016648:

      Having done this, the memento still wasn't properly keyed as the function for creating the keys does not handle arrays being passed as values.

      lib\ezutils\classes\ezoperationmemento.php
      line 170

      I changed the "createKey" function to the following:

          static function createKey( $parameters )
          {
              $string = '';
              foreach ( $parameters as $key => $value )
              {
      			if ( is_array( $value ) ) 
      			{
      				$string .= $key;
      				foreach ( $value as $val ) 
      				{
      		            $string .= $val;
      				}
      			} else {
      	            $string .= $key . $value;
      			}
              }
              return md5( $string );
          }
      

      This fixed the issue.

      Attachments

        Activity

          People

            andre1 andre1
            mjmelli mjmelli
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: