In the cart, add variation selected data to the permalink.

Closes #6060
This commit is contained in:
Mike Jolley 2014-11-27 15:04:24 +00:00
parent 2cfaead676
commit 3415b5d7c0
4 changed files with 7 additions and 5 deletions

View File

@ -171,10 +171,11 @@ class WC_Product_Variation extends WC_Product {
/**
* Wrapper for get_permalink. Adds this variations attributes to the URL.
*
* @param $cart item array If the cart item is passed, we can get a link containing the exact attributes selected for the variation, rather than the default attributes.
* @return string
*/
public function get_permalink() {
return add_query_arg( array_filter( $this->variation_data ), get_permalink( $this->id ) );
public function get_permalink( $cart_item = null ) {
return add_query_arg( array_filter( isset( $cart_item['variation'] ) ? $cart_item['variation'] : $this->variation_data ), get_permalink( $this->id ) );
}
/**

View File

@ -160,6 +160,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
* Tweak - Moved 'Proceed to checkout' button on cart to beneath totals.
* Tweak - Improved 'responsiveness' of product data tabs on add/edit product screen.
* Tweak - Added 'stupidtable' script to allow order item sorting on the order screen (by name, cost, qty).
* Tweak - In the cart, add variation selected data to the permalink.
* Dev - API - Look up product by sku.
* Dev - Made template debug mode set WC_TEMPLATE_DEBUG_MODE constant and remove all overrides for all template loading functions.
* Dev - Switched to .scss from .less for all styles.

View File

@ -55,7 +55,7 @@ do_action( 'woocommerce_before_cart' ); ?>
if ( ! $_product->is_visible() )
echo $thumbnail;
else
printf( '<a href="%s">%s</a>', $_product->get_permalink(), $thumbnail );
printf( '<a href="%s">%s</a>', $_product->get_permalink( $cart_item ), $thumbnail );
?>
</td>
@ -64,7 +64,7 @@ do_action( 'woocommerce_before_cart' ); ?>
if ( ! $_product->is_visible() )
echo apply_filters( 'woocommerce_cart_item_name', $_product->get_title(), $cart_item, $cart_item_key );
else
echo apply_filters( 'woocommerce_cart_item_name', sprintf( '<a href="%s">%s</a>', $_product->get_permalink(), $_product->get_title() ), $cart_item, $cart_item_key );
echo apply_filters( 'woocommerce_cart_item_name', sprintf( '<a href="%s">%s</a>', $_product->get_permalink( $cart_item ), $_product->get_title() ), $cart_item, $cart_item_key );
// Meta data
echo WC()->cart->get_item_data( $cart_item );

View File

@ -37,7 +37,7 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php if ( ! $_product->is_visible() ) : ?>
<?php echo str_replace( array( 'http:', 'https:' ), '', $thumbnail ) . $product_name; ?>
<?php else : ?>
<a href="<?php echo get_permalink( $product_id ); ?>">
<a href="<?php echo esc_url( $_product->get_permalink( $cart_item ) ); ?>">
<?php echo str_replace( array( 'http:', 'https:' ), '', $thumbnail ) . $product_name; ?>
</a>
<?php endif; ?>