In the cart, add variation selected data to the permalink.
Closes #6060
This commit is contained in:
parent
2cfaead676
commit
3415b5d7c0
|
@ -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 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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; ?>
|
||||
|
|
Loading…
Reference in New Issue